Java application—SS2.1

来源:互联网 发布:鸡汤网络中是什么意思 编辑:程序博客网 时间:2024/04/30 11:54

Java语言中命名约定:
1.类名和接口名。每个字的首字母大写,含有大小写。
2.方法名。首字的首字母小写,其他字的首字母大写,含有大小写,尽量少用下划线。
3.常量名。基本数据类型的常量名使用全部大写字母,字与字之间用下划线做间隔。对象常量可以大小混写。
4.变量名。可以大小混写,首字符小写,字间分割用首字母大写分割,不用下划线,少用美元符号$。
关键字:(百度都有)
abstract assert boolean break byte
case catch char class const
continue default do double else
enum extends final finally float
for goto if implements import
instanceof int interface long native
new package private protected public
return strictfp short static super
switch synchronized this throw throws
transient try void volatile while
基本数据类型:
字节型byte 1个字节
短整型short 2个字节
整型int 4个字节
长整型long 8个字节
单精度型float 4个字节
双精度型double 8个字节
字符型char 2个字节(Java采用unicode而不是ascii)
布尔型boolean 8个字节(取值是true和false)、
强转实例:

import java.io.*;public class Eg2_1{    public static void main(String args[])    {        byte a;        int b=325;        double c=346.23;        a=(byte)b;        System.out.println("int->byte:"+b+"->"+a);        b=(int)c;        System.out.println("double->int:"+c+"->"+b);        a=(byte)c;        System.out.println("double->byte:"+c+"->"+a);    }}
0 0
原创粉丝点击