/** * troisieme exemple a essayer * * @author stage IPI IUP2 **/ public class Variables { /** Utilisation de plusieurs variables **/ public static void main ( String [] arg ) { boolean fini = false; int k = 0xF; long n = 32; short s = 24; byte b = 12; // long k = 2147483650; erreur a la compilation: integer too long // long p = 2000*2000000; erreur a l'execution: debordement // float f =8.5; erreur a la compilation: possible loss of precision // float g = 3e40f; erreur a la compilation: floating point number too large double x = 10 * 1e308; float f = 1e38f; float f2 = f*f; float f3 = f*f*f; float g1 = 1.23456789E8f; float g2 = 1.23456789E15f; char c= '\''; char d= 'é'; System.out.println ( k + n +" "+ s +" "+ (-b) +" "+ x +" "+ (10*f)); System.out.println ( f2/f3); System.out.println ( (int) c +" "+ (int)d); System.out.println ( (char) f +" "+(byte) f +" "+ (float) c); System.out.println ( (int) g1 +" "+(short) g1); System.out.println ( (int) g2 +" "+(short) g2); if( fini = true) // fausse comparaison System.out.println ("fini"); else System.out.println ("pas fini"); } }