Alguem poderia me ajudar?
Qual o Maior e o menos valor em Hexadecimal que um int do Java pode Representar
5 Respostas
Dica, imprima em hexadecimal os valores Integer.MAX_INTEGER e Integer.MIN_INTEGER.
System.out.println("%x", Integer.MAX_INTEGER);
System.out.println("%x", Integer.MIN_INTEGER);
Dica, imprima em hexadecimal os valores Integer.MAX_INTEGER e Integer.MIN_INTEGER.System.out.println("%x", Integer.MAX_INTEGER); System.out.println("%x", Integer.MIN_INTEGER);
Vini eu queria aprender essa dica mas tive um erro aqui
códigopublic class NewClass {
public static void main(String [] args){
System.out.println("%x", Integer.MAX_INTEGER);
System.out.println("%x", Integer.MIN_INTEGER);
}
}
exception
run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.io.PrintStream.println
at NewClass.main(NewClass.java:16)
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)
Fiz isso no NBeans.
abraço.
Dica, imprima em hexadecimal os valores Integer.MAX_INTEGER e Integer.MIN_INTEGER.System.out.println("%x", Integer.MAX_INTEGER); System.out.println("%x", Integer.MIN_INTEGER);Vini eu queria aprender essa dica mas tive um erro aqui
códigopublic class NewClass { public static void main(String [] args){ System.out.println("%x", Integer.MAX_INTEGER); System.out.println("%x", Integer.MIN_INTEGER); } }exception
run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.io.PrintStream.println
at NewClass.main(NewClass.java:16)
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)Fiz isso no NBeans.
abraço.
Você não compilou o código (esse erro ocorre quando o IDE vai rodar o código e ele não pôde ser compilador porque tinha erros). Ao compilar, verá alguns erros. Um código correto é:
public class NewClass {
public static void main(String [] args) {
System.out.printf("%x%n", Integer.MAX_VALUE);
System.out.printf("%x%n", Integer.MIN_VALUE);
}
}
Dica, imprima em hexadecimal os valores Integer.MAX_INTEGER e Integer.MIN_INTEGER.System.out.println("%x", Integer.MAX_INTEGER); System.out.println("%x", Integer.MIN_INTEGER);Vini eu queria aprender essa dica mas tive um erro aqui
códigopublic class NewClass { public static void main(String [] args){ System.out.println("%x", Integer.MAX_INTEGER); System.out.println("%x", Integer.MIN_INTEGER); } }exception
run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.io.PrintStream.println
at NewClass.main(NewClass.java:16)
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)Fiz isso no NBeans.
abraço.
Você não compilou o código (esse erro ocorre quando o IDE vai rodar o código e ele não pôde ser compilador porque tinha erros). Ao compilar, verá alguns erros. Um código correto é:
public class NewClass { public static void main(String [] args) { System.out.printf("%x%n", Integer.MAX_VALUE); System.out.printf("%x%n", Integer.MIN_VALUE); } }
Ok, agora consegui.
Saída foi:
run:
7fffffff
80000000
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)
É isso mesmo?
Isso aí, eu comi bola, era printf ali.