扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
public class Admins implements Userinterface{
创新互联建站是一家专注于做网站、网站建设与策划设计,浑南网站建设哪家好?创新互联建站做网站,专注于网站建设10多年,网设计领域的专业建站公司;建站业务涵盖:浑南等地区。浑南做网站价格咨询:13518219792
private String name;
private String password;
private static int userNum;
public Admins() {
userNum ++;
}
public Admins(String name, String password) {
this.name = name;
this.password = password;
userNum ++;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return this.password;
}
public String toString() {
return "Total: " + Admins.userNum + "\nName: " + this.name + "\nPassword: " + this.password;
}
public static void main(String [] args) {
Userinterface [] users = new Userinterface[]{new Admins("jeryy", "11111"), new Admins("green", "123123")};
for(Userinterface u: users) {
System.out.println(u);
}
}
}
interface Userinterface{
public void setPassword(String password);
public String getPassword();
public String toString();
}
public class Bins{
public static void main(String [] args) {
int len = 10;
int [] dist = new int [len];
for(int i = 0; i dist.length; i ++) {
dist[i] = (int)(Math.random() * 100);
}
java.util.Arrays.sort(dist);
System.out.println("生成数组如下: ");
for(int i: dist) {
System.out.print(i + "\t");
}
java.util.Scanner san = new java.util.Scanner(System.in);
System.out.print("输入要查找的数: ");
int key = san.nextInt();
int res = Bins.binSearch(dist, key);
//System.out.println(res);
String info = (res =0 ) ? (key + ":" + res) : "查找失败";
System.out.println(info);
}
public static int binSearch(int [] dist, int key) {
java.util.Arrays.sort(dist);
return java.util.Arrays.binarySearch(dist, key);
}
}
面向对象编程(oop)旨在将现实世界中的概念模拟到计算机中,它将现实世界中的所以事物视作对象。对象是存在的具体实体,具有明确定义的状态和行为。
public static void main(String args[]) {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入一个开始数字:");
int a = 0;
try {
a = scanner.nextInt();
} catch (Exception e) {
System.out.println("输数字不合法");
return;
}
System.out.println("请输入一个结束数字:");
int b = 0;
try {
b = scanner.nextInt();
} catch (Exception e) {
System.out.println("输数字不合法");
return;
}
int sum = 0;
if (a b) {
for (int i = b; i = a; i++) {
sum = sum + i;
}
} else {
for (int i = a; i = b; i++) {
sum = sum + i;
}
}
System.out.println(sum);
}
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流