.


:




:

































 

 

 

 


.




, , , , . , , , . , ( , - ).

Location. , m1, .

 

public class Location {

public int x=0,y=0;

 

public Location (int x, int y) {

this.x=x;

this.y=y;

}

}

 

:

 

Location locat1=new Location(10,20);

 

public static void m1(Location obj){

obj.x++;

obj.y++;

}

locat1 Location, x y 10 20. m1 1 x y , obj.

. x y , locat1. m1.

 

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

System.out.println("locat1.x="+locat1.x);

System.out.println("locat1.y="+locat1.y);

}

 

 

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

m1(locat1);

System.out.println(" m1(locat1)";

}

 

, m1(locat1) locat1.x locat1.y.

 

, . m1:

public static void m1(Location obj){

obj.x++;

obj.y++;

obj=new Location(4,4);

obj.x++;

obj.y++;

}

, , obj, , . x y , locat1 1 ? !

, obj=new Location(4,4); , obj , . obj.x++ obj.y++ . , .

, . , . , . . , obj.x++ , . x obj, , - ! x , obj , .

( ) , , . Java , , , . , . , . Java . Java .

 

, .

, . , , , s3 , s1 s2:

 

void strAdd1(String s1,s2,s3){

s3=s1+s2;

}

 

Java , . , s3. :

obj1.strAdd1(t1,t2,t3);

t3 . , Java String , s1+s2 . s3=s1+s2 s3 . , , t3 -. , , strAdd1 , .

 

: . , , , . , , name+count. , ( ). , .

:

String componentName="myComponent";

int count=0;

public void calcName1(String name) {

count++;

name+=count;

System.out.println(" ="+name);

}

, :

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

calcName1(componentName);

System.out.println("componentName="+componentName);

}

, , componentName myComponent1, myComponent2, . myComponent , calcName1 , . , ?

, , . - , name. componentName - "myComponent".

 

? .

-, -, , -, String:

 

public String calcName2(String name) {

count++;

name+=count;

return name;

}

 

, :

 

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

componentName=calcName2(componentName);

System.out.println("componentName="+componentName);

}

, , . .

-, . count , .

-, (wrapper), . , . , , -. , . , - , , , . .

-, StringBuffer StringBuilder. , , . .

 

public void calcName3(StringBuffer name) {

count++;

name.append(count);

System.out.println(" ="+name);

}

 

StringBuffer sbComponentName=new StringBuffer();

{sbComponentName.append("myComponent");}

 

private void jButton8ActionPerformed(java.awt.event.ActionEvent evt){

calcName3(sbComponentName);

System.out.println("sbComponentName="+sbComponentName);

}

 

componentName sbComponentName StringBuffer. - , , sbComponentName . . String , , StringBuffer, , .

, StringBuffer StringBuilder , String. toStringBuffer() . StringBuffer sb.append(). append insert . , , . ,

int[] a=new int[]{10,11,12};

System.out.println("a="+a);

:

a=[I@15fea60

, .

 

- . , :

 

void m1(Double d){

d++;

}

 

, d , d , String. double, ++. Double, d.

:

public void proc1(Double d1,Double d2,Double d3){

d3=d1+sin(d2);

}

 

, , d3, d3=d1+sin(d2), , .

, , . . :

 

public class UsableDouble{

Double value=0;

 

UsableDouble(Double value){

this.value=value;

}

}

 

UsableDouble d . .

, , , , .

, , Java , , , , Java- C#.





:


: 2017-02-28; !; : 661 |


:

:

, .
==> ...

1565 - | 1366 -


© 2015-2024 lektsii.org - -

: 0.022 .