I started learning Java's notes, now preliminarily, now it is posted! The first part

xiaoxiao2021-03-06  61

5.

Public Class Dog

{public string color = "black";

// private int weight = 10;

/ **

Weight property, if you are private (private)

You can't access it in other classes.

* /

PUBLIC INT weight = 10;

/ **

AA method, if you are private (private)

You can't access it in other classes.

* / / // private void aa ()

Private void aa ()

{

}

/ **

a method

* /

Public void a ()

{

System.out.println (Color);

}

/ **

B method

* /

Public void b ()

{

System.out.println (weight);

}

/ **

C method

* /

Public void C (String CC)

{

Color = CC;

}

/ **

D method

* /

Public void d (int WW)

{

Weight = ww;

}

}

6.

Package abc.efg.xyz;

// In the bag, you have to add the public package to access

Public Class Person

{

// In the bag, you have to add the public package to access

Public int Age = 10;

// In the bag, you have to add the public package to access

Public String Name = "Zhang San";

// In the bag, you have to add the public package to access

Public void a ()

{

}

}

转载请注明原文地址:https://www.9cbs.com/read-84438.html

New Post(0)