作业 金嘉琪0918

编程入门 行业动态 更新时间:2024-10-24 16:24:35

<a href=https://www.elefans.com/category/jswz/34/1771149.html style=作业 金嘉琪0918"/>

作业 金嘉琪0918

1输出一个长整型

public class Long
{
  public static void main(String[] args)
  {
  long l=123456789123;
    System.out.println("长整型变量为:"+l);
  }
}

 

 

 

 

 

 

2输出一个单精度常量
public class Float
{
  public static void main(String[] args)
    {
      float f=(float)2.4;
      System.out.println("单精度常量:"+f);
    }
}

 

 

 

 

 

 

3输出一个布尔型

public class Boolean
{
  public static void main(String[] args)
  {
    boolean b=true;
    b=false;
    System.out.println("布尔型:"+b);
  }
}

 

 

 

 

 

4强制转换

public class Byte
{
  public static void main(String[] args)
    {
      byte b=3;
      b=(byte)(b+200);
      System.out.println("强制转换:"+b);
    }
}

 

 

 

 

 

 

 

 

5字符型加法运算
public class CharSum
{
  public static void main(String[] args)
    {
      System.out.println('a'+1);
      System.out.println((char)('a'+1));
      System.out.println((char)('你'+1));
    }

}

 

 

 

6

public class Overflow
{
  public static void main(String[] args)
  {
    int big=0x7fffffff;
    System.out.println(big);
  }
}

 

 

 

 

 

 

7计算

public class SumChar
{
  public static void main(String[] args)
  {
    int x=20;
    x=x/2*100;
    System.out.println("得出:"+x);
  }
}

 

 

 

 

转载于:.html

更多推荐

作业 金嘉琪0918

本文发布于:2024-03-13 10:38:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1733796.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   金嘉琪

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!