J'ai écrit mon tout premier programme java sur eclipse sous Windows. J'ai récemment commencé à programmer java sur linux.java: conversion de type simple
Lorsque j'essaie de compiler le programme ci-dessus sous Linux, cela fonctionne très bien mais lorsque j'essaie de le faire sous Windows, j'obtiens l'erreur suivante.
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);
}
}
Si quoi que ce soit, il est tout à fait étrange que ce code compile sous Linux. Quel compilateur utilisez-vous? Est-ce vraiment le même code exact? – Dolda2000