public class bl07 {
String name;
String num;
int a,b;
public void AAA() {
int num1=20;
System.out.println(name);
System.out.println(num);
System.out.println(a);
System.out.println(b);
System.out.println(num1);
}
}
public class So {
public static void main(String[] args) {
bl07 sa=new bl07();
sa.AAA();
sa.b=25;
System.out.println("=========");
System.out.println(sa.num);
System.out.println(sa.b);
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/541664f191fa75a903bc8b13413fa56b.png)
public class jicheng {
public static void main(String[] args) {
int[] a= {1123,4545,788,545,21} ;
int max=getmax(a);
System.out.println("最大值:"+max);
}
public static int getmax(int[] a) {
int max=a[0];
for(int i=1;i<a.length;i++) {
if(a[i]>max) {
max=a[i];
}
}
return max;
}
}
public class da {
private String name;
private String from;
private int age;
private boolean male;
public void setName(String name) {
this.name=name;
}
public String getName() {
return name;
}
public void setFrom(String from) {
this.from=from;
}
public String getFrom() {
return from;
}
public void setAge(int num) {
if(num<100 && num>=0) {
age = num;
}else {
System.out.println("数据不合理");
}
}
public int getAge() {
return age;
}
public void setMale(boolean boy) {
male=boy;
}
public boolean ismale() {
return male;
}
public void show() {
System.out.println("My name is "+name+",I'm from "+from+", "+age+" years old this year");
}
public void introduce() {
System.out.println(name+","+from+"突击步枪");
}
}
public class xiao {
public static void main(String[] args) {
da xxx=new da();
xxx.setName("Jack");
xxx.setAge(18);
xxx.setFrom("England");
xxx.setMale(true);
System.out.println(xxx.getName());
System.out.println(xxx.getAge());
System.out.println(xxx.getFrom());
System.out.println(xxx.ismale());
if(xxx.ismale()==true) {
System.out.println("man");
}else {
System.out.println("woman");
}
System.out.println("=================");
xxx.show();
System.out.println("=================");
da sss=new da();
sss.setName("G36");
sss.setFrom("德国");
System.out.println(sss.getName());
System.out.println(sss.getFrom());
sss.introduce();
}
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/c9eb47b461c9123ffc5599a22b31cd8a.png)