public class Admins implements Userinterface{
創(chuàng)新互聯(lián)建站是一家專(zhuān)注于做網(wǎng)站、網(wǎng)站建設(shè)與策劃設(shè)計(jì),渾南網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)建站做網(wǎng)站,專(zhuān)注于網(wǎng)站建設(shè)10多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專(zhuān)業(yè)建站公司;建站業(yè)務(wù)涵蓋:渾南等地區(qū)。渾南做網(wǎng)站價(jià)格咨詢(xún):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("生成數(shù)組如下: ");
for(int i: dist) {
System.out.print(i + "\t");
}
java.util.Scanner san = new java.util.Scanner(System.in);
System.out.print("輸入要查找的數(shù): ");
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);
}
}
面向?qū)ο缶幊蹋╫op)旨在將現(xiàn)實(shí)世界中的概念模擬到計(jì)算機(jī)中,它將現(xiàn)實(shí)世界中的所以事物視作對(duì)象。對(duì)象是存在的具體實(shí)體,具有明確定義的狀態(tài)和行為。
public?static?void?main(String?args[])?{
Scanner?scanner?=?new?Scanner(System.in);
System.out.println("請(qǐng)輸入一個(gè)開(kāi)始數(shù)字:");
int?a?=?0;
try?{
a?=?scanner.nextInt();
}?catch?(Exception?e)?{
System.out.println("輸數(shù)字不合法");????????
return;
}
System.out.println("請(qǐng)輸入一個(gè)結(jié)束數(shù)字:");
int?b?=?0;????
try?{
b?=?scanner.nextInt();
}?catch?(Exception?e)?{
System.out.println("輸數(shù)字不合法");????????
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);
}