public class lianxi11 {
public static void main(String[] args) {
int count = 0;
for(int x=1; x<5; x++) {
for(int y=1; y<5; y++) {
for(int z=1; z<5; z++) {
if(x != y && y != z && x != z) {
count ++;
System.out.println(x*100 + y*10 + z );
}
}
}
}
System.out.println("共有" + count + "个三位数");
}
}
import java.util.*;
public class lianxi15 { public static void main(String[] args) {
input fnc = new input();
int x=0, y=0, z=0;
System.out.print("输入第一个数字:");
x = fnc.input();
System.out.print("输入第二个数字:");
y = fnc.input();
System.out.print("输入第三个数字:");
z = fnc.input();
if(x > y) {
int t = x;
x = y; y = t;
}
if(x > z) {
int t = x;
x = z; z = t;
}
if(y > z) {
int t = y;
y = z;
z = t;
}
System.out.println( "三个数字由小到大排列为: "+x + " " + y + " " + z);
}
}
class input{ public int input() {
int value = 0;
Scanner s = new Scanner(System.in);
value = s.nextInt();
return value;
}
}
public class lianxi16 {
public static void main(String[] args) {
for(int i=1; i<10; i++) {
for(int j=1; j<=i; j++) {
System.out.print(j + "*" + i + "=" + j*i + " " );
if(j*i<10){System.out.print(" ");
}
} System.out.println();
}
}
}
import java.util.*;
public class lianxi28 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int[] a = new int[10];
System.out.println("请输入10个整数:");
for(int i=0; i<10; i++) {
a[i] = s.nextInt();
}
for(int i=0; i<10; i++) {
for(int j=i+1; j<10; j++) {
if(a[i] > a[j]) {
int t = a[i];
a[i] = a[j];
a[j] = t;
}
}
}
for(int i=0; i<10; i++) {
System.out.print(a[i] + " ");
}
}
}
1.父类:
public class A {
public int a = 0;
public void fun(){
System.out.println("-----A-----");
}
}
子类:public class B extends A{
public int a = 1;
public void fun(){
System.out.println("-----B-----");
}
主方法:
public static void main(String[] args){
A classA = new B();
System.out.println(classA.a);
classA.fun();
}
}
2.父类:
public class Monkey{ public Monkey (String s) { System.out.println(s); } public void speak() { System.out.println("咿咿呀呀......"); } } 子类:
public People extends Monkey { public People() {} public void speak() { System.out.println("小样的,不错嘛!会说话了!"); } public void think() { System.out.println("别说话!认真思考!"); } } 子类:
public class E{ public void main(String[] args) { Monkey monkey = new Monkey("我是猴子"); monkey.speak(); People people = new People(); people.speak(); people.think(); } }