I have an error in my code because I am using a String like a Switch case:
private static void setNumberValues(Employee emp, Address address,
String keyName, long value, List<Long> phoneNums) {
switch(keyName){
case "zipcode":
address.setZipcode((int)value);
break;
case "id":
emp.setId((int) value);
break;
case "phoneNumbers":
phoneNums.add(value);
break;
default:
System.out.println("Unknown element with key="+keyName);
}
}
I am facing this error in Visual Studio Code with the Red Hat Java extension.
I know what the error means so, here is my environment:
My jdk version:
/usr/libexec/java_home -V
Matching Java Virtual Machines (1):
1.8.0_131, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
My Visual Studio Code java.home settings:
"java.home": "/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home"
How to tell VSC to compile with my jdk 1.8 and don't bother with old java 1.6 ?
Regards,
S.