senthilmpro
BAN USERimport java.util.HashMap;
public class EmployeeDictionary {
public static void main(String[] args) {
HashMap<String,String> empHashMap = new HashMap<String,String>();
empHashMap.put("A", "C");
empHashMap.put("B", "C");
empHashMap.put("C", "F");
empHashMap.put("D", "E");
empHashMap.put("E", "F");
empHashMap.put("F", "F");
getManagerDict(empHashMap);
}
/* Function to count Managers */
public static void getManagerDict(HashMap<String,String> empHashMap){
int[] arr = new int[empHashMap.size()];
for(String key : empHashMap.keySet())
{
int value = empHashMap.get(key).charAt(0) - 65;
arr[value]++;
}
for(int i = 0; i< arr.length ; i++)
{
String asciiVal = Character.toString((char) (i + 65));
System.out.println(asciiVal + " - "+ arr[i]);
}
}
}
OUTPUT :
A - 0
B - 0
C - 2
D - 0
E - 1
F - 3
import java.io.File;
public class FileDiscovery {
public static void main(String[] args) {
getFile("/home/user/Desktop");
}
public static void getFile(String Path)
{
File arry = new File(Path);
if(arry.isDirectory())
{
File[] dir = arry.listFiles();
for(File myFile : dir)
getFile(myFile.getAbsolutePath());
}
else
{
System.out.println(arry.getAbsolutePath());
}
}
}
- senthilmpro May 05, 2015