我已经在 windows 上的 eclipse 上编写了我的第一个 java 程序。我最近开始在 linux 上编写 java 程序。
当我尝试在 Linux 上编译上述程序时,它确实可以正常工作,但是当我尝试在 Windows 上编译时,出现以下错误。
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Type mismatch: cannot convert from int to short
Type mismatch: cannot convert from double to float
public class TypeDemo {
public static void main (String args[])
{
byte b = 8;
long a = 1000011334;
int c = 76;
short s = 99789;
float f = 99.99;
double d = 99979.9879;
boolean bool = true;
char ch = 'y';
System.out.println ("b = "+b);
System.out.println ("a = "+a);
System.out.println ("c = "+c);
System.out.println ("s = "+s);
System.out.println ("f = "+f);
System.out.println ("d = "+d);
System.out.println ("bool = "+bool);
System.out.println ("ch = "+ch);
}
}