当前位置: 代码迷 >> Eclipse >> 生手求大神指导~
  详细解决方案

生手求大神指导~

热度:21   发布时间:2016-04-23 02:10:59.0
新手求大神指导~~~
public class SimpleTypes{
  public static void main(String[] args){
  System.out.printf("byte \t数值范围: %d ~ %d\n",Byte.MAX_VALUE, Byte.MIN_VALUE);
  System.out.printf("short \t数值范围:%hd ~ %hd\n",Short.MAX_VALUE, Short.MIN_VALUE);
  System.out.printf("int \t数值范围: %d ~ %d\n",Integer.MAX_VALUE, Integer.MIN_VALUE);
  System.out.printf("long \t数值范围:%ld ~ %ld\n",Long.MAX_VALUE, Long.MIN_VALUE);
  System.out.printf("char \t数值范围: %c ~ %c\n",Character.MAX_VALUE, Character.MIN_VALUE);
  System.out.printf("float \t数值范围: %f ~ %f\n",Float.MAX_VALUE, Float.MIN_VALUE);
  System.out.printf("double \t数值范围:%lf ~ %lf\n",Double.MAX_VALUE, Double.MIN_VALUE);
   
  }
}
为啥char,float,double都不能用呢?我看过这三个都有MAX_VALUE和MIN_VALUE啊。。。求指导。。。
运行结果如下:
byte 数值范围: 127 ~ -128
short 数值范围:7fffd ~ ffff8000d
int 数值范围: 2147483647 ~ -2147483648
Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = 'l'
at java.util.Formatter$FormatSpecifier.conversion(Formatter.java:2606)
at java.util.Formatter$FormatSpecifier.<init>(Formatter.java:2634)
at java.util.Formatter.parse(Formatter.java:2480)
at java.util.Formatter.format(Formatter.java:2414)
at java.io.PrintStream.format(PrintStream.java:920)
at java.io.PrintStream.printf(PrintStream.java:821)
at SimpleTypes.main(SimpleTypes.java:7)

------解决方案--------------------
探讨
public class SimpleTypes{
public static void main(String[] args){
System.out.printf("byte \t数值范围: %d ~ %d\n",Byte.MAX_VALUE, Byte.MIN_VALUE);
System.out.printf("short \t数值范围:%hd ~ %h……
  相关解决方案