2015-07-27
来源:互联网 发布:linux 搭建OpenVPN 编辑:程序博客网 时间:2024/04/27 22:38
int farray[]=new int[3];//int specify the type of the element,[] indicate that 'farray' is an array //********************************************************************************* String [] stringArray=new String[3];//array can be also defined this way stringArray[0]="this is my reburn";//the elements which don't be assigned value manually will be null //**************************************************************** int intArray[]; intArray=new int[3];//this is another way to define an array:declare then assign space //********************************************************************** //***************************initialization******************************************** int f2array[]={1,2,3}; String [] string2Array={"string1","string2"};//initialize while declaring,this way is also known as static initailization int f3array[]=new int[5]; f3array[0]=1; f3array[2]=4;//***************** it will be 0 where you didnot assign value Scanner s=new Scanner(System.in);//receive the data from console while(s.hasNext()){ String line=s.nextLine(); if (line.equals("exit")) { break; } if (line=="exit") {//cannot compare the content of two strings by '==',as for basic data type '==' will compare their values,but for complex the comparasion is address System.out.println("you choose to exit"); } System.out.println(line=="exit"); } for (int i=0;i<f3array.length ; i++) { System.out.println(f3array[i]); } String s1="hello"; String s2="hello"; System.out.println(s1.equals(s2)); //*******************************constants in java***************** In Java,contants are declared by final keywords not const. System.out.println(NUM); //*********************************not changable string************cant change the data where string variables refer to******* String a="hello"; //*****************************************build string******************* StringBuilder builder=new StringBuilder(); String b="java"; builder.append(a); builder.append(b); b=builder.toString(); System.out.println(b); //*****************************************scanner********* System.out.println("what's your name?\n"); Scanner in=new Scanner(System.in); System.out.println("your name is "+in.nextInt()); //***************************************************console********** Console cons=System.console(); String username=cons.readLine("what's your name?"); char [] pwd=cons.readPassword("password:"); //****************************************formatting output******* double x=100000/3; System.out.printf("%0f",x); //**************************************************************
0 0
- 2015-07-27总结
- 2015/07/27
- [2015-07-27] python009
- 2015-07-27
- 2015-07-27
- java培训 2015-07-27
- 2015-07-27 悲催的我
- 2015/07/27第一天小记
- BNU Training 2015 07 27 题解
- 小白学开发(iOS)OC_多态(2015-07-27)
- 小白学开发(iOS)OC_类的本质(2015-07-27)
- 小白学开发(iOS)OC_成员变量的作用域(2015-07-27)
- 小白学开发(iOS)OC_ 点语法(2015-07-27)
- 05/07/27
- 书签(2006-07-27)
- 周球报(07-5-27)
- 2009-07-27 TIPTOP
- 10 07 27 开会
- POJ 3347 && HDU 2417 Kadj Squares(计算几何)
- HDU 1829 A Bug's Life (并查集)
- Android什么时候只会调用onPause()而不会调用onStop()?
- 耐人寻味的Temp文件(三)
- HDU 2601An easy problem-素数的运用,暴力求解
- 2015-07-27
- mongodb collections类型转换
- SSM框架搭建
- GTK常用控件之进度条( GtkProgressBar )
- ios -UI-UI-菜单栏+导航栏
- ElasticSearch笔记
- Objective-C编程规范
- poj 1733 Parity game(种类并查集)
- Bitmap和Drawable的互相转换