加入收藏
网站地图
网站搜索
阅读内容

Java入门教程:数据类型举例

[日期:2010-03-11] 来源:Linux社区  作者:Linux

  下例中用到了前面提到的数据类型,并通过屏幕显示它们的值。

  public class SimpleTypes{

  public static void main( String args[] ){

  byte b=0x55;

  short s=0x55ff;

  int i=1000000;

  long l=0xfffL;

  char c='c';

  float f=0.23F;

  double d=0.7E-3;

  boolean bool=true;

  System.out.println("b = "+b);

  System.out.println("s = "+s);

  System.out.println("i = "+i);

  System.out.println("c = "+c);

  System.out.println("f = "+f);

  System.out.println("d = "+d);

  System.out.println("bool = "+bool);

  }

  }

  编译并运行该程序,输出结果为:

  C:\>java SimpleTypes

  b = 85

  s = 22015

  i = 1000000

  l = 4095

  c = c

  f = 0.23

  d = 0.0007

  bool = true




相关资讯       Java 
本文评论       全部评论
发表评论

请您注意:
遵守国家有关法律、法规,尊重网上道德,承担一切因您的行为而直接或间接引起的法律责任。
LinuxIDC.com拥有管理笔名和留言的一切权利。

点评: 字数
姓名: