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的更多相关文章
随机推荐
- Oracle Database 12c Release 1 Installation On Oracle Linux 6.4 x86_64
Create groups and users [root@vmdb12c ~]# groupadd oinstall [root@vmdb12c ~]# groupadd dba [root@vmd ...
- MFC自绘控件学习总结第二贴---转
首先感谢大家对第一帖的支持,应一些网友烈要求下面我在关于上一贴的一些补充和说明(老鸟可以无视)这一贴是实战+理论不知道第一帖的先看第一帖:http://topic.csdn.net/u/2011071 ...
- 在优化SQL语句中使用虚拟索引
定义:虚拟索引(virtual index) 是指没有创建对应的物理段的索引. 虚拟索引的目的:是在不损耗主机CPU,IO,磁盘空间去实际创建索引的情况下,来判断一个索引是否能够对SQL优化起到作用. ...
- Android:源码环境编译自定义的APP到ROM(System Image)中
有时候我们需要在源码环境中增加自己的应用或模块,随ROM一起发布. 下面讲述相关步骤: 1. 首先可以在SDK环境下进行编码设计(如果你的APP不涉及到emulator无法模拟的硬件的话) 也可以参考 ...
- POJ2395 最小生成树 - Prime算法
题目: Out of Hay Time Limit: 1000MS Memory Limit: 65536K Total Submissions: Accepted: Description The ...
- 如何自学 Python(干货合集)
http://wenku.baidu.com/view/5108f974192e45361066f583.html
- wget -r -nc -np "http://www.zhihu.com/"
下载网站所有 -r, --recursive specify recursive download. -nc, --no-clobber skip dow ...
- 基于visual Studio2013解决算法导论之044最短路径
题目 最短路径 解决代码及点评 // 26最短路径dijstra.cpp : 定义控制台应用程序的入口点. // #include <iostream> using namespa ...
- Mybatis3 框架理解
最近工作比较闲,维护一个政府机关的短信发送平台,大部分业务逻辑都在Oracle数据库上,但自己明明应聘的是Java开发啊!!!整天写存储过程的我还是有一颗写高级语言的心啊!!!好吧!!!先找个数据库方 ...
- PHP - 多文件上传
<html> <head> <meta charset="utf-8"> <title>index_uploads</titl ...