chapter2 变量和常量
来源:互联网 发布:软件测试书籍电子版 编辑:程序博客网 时间:2024/05/18 02:14
package com.xx.lixiaotao;/*** * my first HelloWorld project in xx * @author lixiaotao * 在Java的道路上,走好每一步 * */public class FirstHelloWorld { public static void main(String arg[]){ // part1 String name="lixiaotao"; char sex='男'; int num=27; double price=120.5; boolean isOK=true; System.out.println(name); System.out.println(sex); System.out.println(num); System.out.println(price); System.out.println(isOK); // part2 String city="腾冲"; System.out.println("my hometown is"+ city); // part3 // Java中的自动类型转换 /* *int 类型可自动转换为 double 类型,但 double 类型不能自动转换为 int 类型 */ double avg1=78.5; int rise=5; double avg2=avg1+rise; System.out.println("考试平均分:"+avg1); System.out.println("调整后的平均分:"+avg2); // part4 // Java中的强制类型转换 double heightAvg1=176.2; int heightAvg2=(int)heightAvg1; //强制转换 System.out.println(heightAvg1); System.out.println(heightAvg2); // part5 //Java常量的应用 ///常量名一般使用大写字符 //// 语法:final 常量名 = 值; final String MALE="男,我是常量"; final String FEMALE ="女,我是常量"; System.out.println(MALE); System.out.println(FEMALE); }}
0 0
- chapter2 变量和常量
- chapter2.变量和基本类型
- Chapter2 变量和基本类型
- 变量和常量,数组
- 常量和变量
- 变量和常量
- 数据类型、常量和变量
- 变量和常量
- Js_常量和变量
- 字符串常量和变量
- (二) 变量和常量
- Ruby变量和常量
- go - 变量和常量
- Java 变量和常量
- 常量和变量
- Swift--变量和常量
- Swift--变量和常量
- Swift常量和变量
- 单行函数(日期函数)
- windows7 64位安装Apache2.4
- 蒙特利尔问题(三门问题)的解释
- Objective-C入门知识
- Machine Learning内容梳理
- chapter2 变量和常量
- 《用tcp/ip进行网际互联》第7章 网际协议:转发IP数据报 笔记
- tensorflow 笔记1
- Java异常处理的10个最佳实践
- cocos2dx——lua
- POJ 1743 Musical Theme
- [搜索]八数码问题
- uva348 Optimal Array Multiplication Sequence
- chapter3 常用的运算符