Java_1Lesson
cmd使用
进入硬盘分区:D: E: F:
查看目录 dir
进入文件夹 “cd 文件名”
.使用javac编译器编译运行。
Javac 文件名
运行java程序
Java 文件名
第一个程序
public class hello
{
public static void main(String[] arg)
{
System.out.println("hello world");
} }
第二个程序
public class hello
{
public static void main(String[] arg)
{
int s=0;
for(int i=1;i<=100;++i)
s+=i;
System.out.println(s);
} }
第三个程序
public class hello
{
public static void main(String[] arg)
{
int s=0;
for(int i=1;i<=100;++i)
s+=i;
System.out.println(s);
} } class A
{}
class B
{}
class C
{} 会生成四个文件。 了解JVM运行过程
JAVA 编程规范 栈空间:引用变量、基本数据类型、int,float,short,double 默认值为随机的,并且会报错。
堆空间:new分配堆空间,默为值为\0即NULL 变量
特性:
名称:$,字母,下划线可作变量名发头,数字不可以作为开头。
类型:
初始值:
作用域 :
Java中两大数据类型: 基本数据类型:byte,boolean,char,short,int,long,float,double
byte:8位符号整数,boolean:bool类只有ture和flase
引用数据类型:class interface 数组 基本数据类型之间的转换:
不同类型的变量运算,......... 运算符:
.................................
Instanceof 是否是该类的对象。
& 为双目运算,两边的类型必须要相同。
>>> 无符号位移 第三个程序:
public class hello
{
public static void main(String[] arg)
{
int i=1;
switch(i)
{
case 1:System.out.println("A");break;
case 2:System.out.println("B");break;
case 3:System.out.println("C");break;
default:System.out.println("D");break;
}
} } public class hello
{
public static void main(String[] arg)
{
int i=1;
switch(i)
{
case 1:System.out.println("A");
case 2:System.out.println("B");
case 3:System.out.println("C");
default:System.out.println("D");
}
} } 第四个程序:
public class hello
{
public static void main(String[] arg)
{
int x=10; if(x<1)
System.out.println(x);
else if(1<=x&&x<10)
System.out.println(3*x-2);
else
System.out.println(4*x); } } 第五个程序:
public class hello
{
public static void main(String[] arg)
{
int x=1; while(x<5)
{
if(i==3)
{
break;
}
++i;
System.out.println(x);
} } } 第六个程序:
public class hello
{
public static void main(String[] arg)
{
int x=1; while(x<5)
{
if(i==3)
{
continue; //进入死循环
}
++i;
System.out.println(x);
}
} }
Java_1Lesson的更多相关文章
随机推荐
- Publisher/Subscriber 订阅-发布模式
Publisher/Subscriber 订阅-发布模式 本博后续将陆续整理这些年做的一些预研demo,及一些前沿技术的研究,与大家共研技术,共同进步. 关于发布订阅有很多种实现方式,下面主要介绍WC ...
- QT设置前景图位置(配色简单漂亮)
QPushButton { background-image: url(:/Resources/green_click.png); image: url(:/Resources/toolsbutton ...
- HDU 2227 Find the nondecreasing subsequences (线段树)
Find the nondecreasing subsequences Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/3 ...
- stm32之RCC
stm32时钟系统的意义: 1.电源的开关作用,达到低功耗效果: 2.调节时钟的速度: 对于每个外设,都要设置设置,stm32的时钟系统为了更低功耗: STM32时钟系统框图分析: 时钟源: 时钟是S ...
- tomcat 系统服务 outofmemory
TOMCAT内存溢出outofmemory的问题: http://hi.baidu.com/mefeng47/item/3b247af74ce4e24e922af2e5 注:双击tomcat6w.ex ...
- Read and Write NSArray, NSDictionary and NSSet to a File
查询地址:http://iosdevelopertips.com/data-file-management/read-and-write-nsarray-nsdictionary-and-nsset- ...
- ThinkPHP-3.2.3学习
一.下载安装 核心包:不用解释,最减版本 完整包:包括扩展功能(验证码.session等) 二.调试 ----www ---thinkphp_3 Application ...
- Python3.5.1 下使用HTMLParser报错
pip 安装HTMLParser之后,import HTMLParser 使用的时候,报错"ImportError:Can't not find module markupbase" ...
- Python 函数基础、有序集合、文件操作(三)
一.set 特点: set是一个无序且不重复的元素集合访问速度快:天生解决元素重复问题 方法: 初始化 >>> s1 = set()>>> print(type(s ...
- 【集训笔记】计算几何【HDOJ2036【HDOJ1086【HDOJ1115【HDOJ1147【HDOJ1392 【ZOJ2976
改革春风吹满地 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted ...