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的更多相关文章
随机推荐
- 转:不会定义jQuery插件,不要说会jQuery
一:导言 有些WEB开发者,会引用一个JQuery类库,然后在网页上写一写$("#"),$("."),写了几年就对别人说非常熟悉JQuery.我曾经也是这样的人 ...
- Codeforces 41D Pawn 简单dp
题目链接:点击打开链接 给定n*m 的矩阵 常数k 以下一个n*m的矩阵,每一个位置由 0-9的一个整数表示 问: 从最后一行開始向上走到第一行使得路径上的和 % (k+1) == 0 每一个格子仅仅 ...
- img 的 align 属性
AbsBottom 图像的下边缘与同一行中最大元素的下边缘对齐. AbsMiddle 图像的中间与同一行中最大元素的中间对齐. Baseline 图像的下边缘与第一行文本的下边缘对齐. Bottom ...
- setInterval定义与调用
以下是一个倒计时,可以定义定时器为全局变量(ti2),或局部变量(ti). <script type="text/javascript" src="js/jquer ...
- Android:mimeType
接收从其他应用传过来的数据,要用到清单文件 <activity android:name="com.terry.myActivity2" android:label=&quo ...
- iOS XMPP之常见错误一:(<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl"><not-authorized/></failure>)
在XMPP开发中,使用XMPPStream进行连接服务器后,验证过程中,比较常见的一个错误是 <failure xmlns="urn:ietf:params:xml:ns:xmpp-s ...
- Verilog中的标点
在Verilog中有时候会误用的上引号 1,define 中的 `define INITIAL 0 这个单引号用的是键盘左上角的那个单引号,其实就是一个小撇. 2,4'd0 这个 用的是才是叫真正的 ...
- setitimer()函数使用
setitimer()为Linux的API,并非C语言的Standard Library,setitimer()有两个功能,一是指定一段时间后,才执行某个function,二是每间格一段时间就执行某个 ...
- 如何A掉未来程序改
话说有这样一道神题:[集训队互测2015]未来程序·改. 大意是要求写一个简单的C++解释器!这里去掉了C++的许多特性,连简单的break和continue都没有了! 话说NOI被屠了之后,一时心血 ...
- Java 开源博客——B3log Solo 0.6.7 正式版公布了!
Java 开源博客 -- B3log Solo 0.6.7 正式版公布了!欢迎大家下载. 另外,欢迎观摩 B3log 团队的新项目:Wide,也很欢迎大家參与进来 :-) 特性 基于标签的文章分类 P ...