Java backward compatibility description
•
Java
I have a Java class file I compiled with JVM 7 I implemented Java 1.7 additions, such as string switchcase and diamond operator Now I want to run this on Java 1.6 JRE Class file Will it work?
A simple program using string switch, I'm uninstalling 6 Please try and give me the answer
import java.util.Scanner;
public class Classing
{
public static void main(String[] args)
{
System.out.println("Enter a month to kNow who you are");
System.out.println("Jan \n Feb \n Mar \n Apr");
Scanner scan=new Scanner(system.in);
String name=scan.nextLine();
System.out.println(fortune(name.toLowerCase()));
}
public static String fortune(String s)
{
switch(s)
{
case "jan":
return "Good guy";
case "feb":
return "Nice guy";
case "mar":
return "Brave guy";
case "apr":
return "Super guy";
}
return " Month out of option"+s;
}
}
Solution
According to http://www.oracle.com/technetwork/java/javase/compatibility-417013.html#binary , even if there is a recognized answer to this question
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
