?? maintest.java
字號:
/*Main方法由Java虛擬機調(diào)用
*不用產(chǎn)生對象來調(diào)用,故是static*/
/*函數(shù)調(diào)用。。。。*/
/*
*在Java中,傳參時,都是以傳值的方式進行。
*
*對于基本數(shù)據(jù)類型,傳遞的是數(shù)據(jù)的拷貝
*對于引用類型,傳遞的引用的拷貝
*
*/
/*
*看是數(shù)據(jù)作為形參還是引用作為形參
*
*/
class MainTest
{
public static void change(int x,int y)
{
x=x+y;
y=x-y;
x=x-y;
}
public static void change(int[] num)
{
num[0] = num[0]+num[1];
num[1] = num[0]-num[1];
num[0] = num[0]-num[1];
}
public static void change(Point pt)
{
pt.x = pt.x + pt.y;
pt.y = pt.x - pt.y;
pt.x = pt.x - pt.y;
}
public static void main(String[] args)
{
/*
if(args.length>0)
{
for(int i=0; i<args.length;i++)
{
System.out.println(args[i]);
}
}*/
int x=3;
int y=4;
change(x,y);
System.out.println("x="+x+","+"y="+y);
int[] num=new int[]{3,4};
change(num);
System.out.println("x="+num[0]+","+"y="+num[1]);
Point pt = new Point();
pt.x = 3;
pt.y = 4;
change(pt);
System.out.println("x="+pt.x+","+"y="+pt.y);
System.out.println(pt);
/*見toString()方法*/
/*The to String method for class Object returns a string consisting
*of the name of the class of which the object is an instance,the at-sign
*character '@',and the unsigned hexadecimal representation of the hash code
*of the object.In other words,this method returns a string equal to the value of:
*
*getClass().getName() + '@'+ Integer.toHexString(hashCode())
*
*It is recommended that all subclasses override this method;
**/
}
}
class Point
{
int x,y;
public String toString()
{
return "x="+x+":"+"y="+y;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -