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);
}
当前名称:面向对象编程代码java java面向对象编程开发
浏览地址:https://www.cdcxhl.com/article10/dddjpgo.html
成都网站建设公司_创新互联,为您提供搜索引擎优化、域名注册、商城网站、静态网站、品牌网站建设、网站策划
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联