放eclipse里就會有紅線提示,類名和文件名應(yīng)該一致
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:域名注冊、網(wǎng)頁空間、營銷軟件、網(wǎng)站建設(shè)、懷柔網(wǎng)站維護(hù)、網(wǎng)站推廣。
你說的不會報錯不知道是什么情況,默認(rèn)設(shè)置是會報錯的
1:D , b+1中 b是byte類型,1是int類型,相加會有損失無法編譯。
2:B , ch是 char字符類型,無法用算術(shù)運算符運算。
3:D , 因為continue語句的存在,m++語句是無法到達(dá)的 。
Q.下面的代碼片段中,行A和行B所標(biāo)識的代碼有什么區(qū)別呢?
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
public class ConstantFolding {
static final int number1 = 5;
static final int number2 = 6;
static int number3 = 5;
static int number4= 6;
public static void main(String[ ] args) {
int product1 = number1 * number2; //line A
int product2 = number3 * number4; //line B
}
}
A.在行A的代碼中,product的值是在編譯期計算的,行B則是在運行時計算的。如果你使用Java反編譯器(例如,jd-gui)來反編譯ConstantFolding.class文件的話,那么你就會從下面的結(jié)果里得到答案。
?
1
2
3
4
5
6
7
8
9
10
11
12
13
public class ConstantFolding
{
static final int number1 = 5;
static final int number2 = 6;
static int number3 = 5;
static int number4 = 6;
public static void main(String[ ] args)
{
int product1 = 30;
int product2 = number3 * number4;
import java.io.*;
import java.util.*;
class tel{
int empno;
String empname;
String empdept;
String empph;}
class phone
{public static void main(String args[])
{tel emp[],emp1[];
emp=new tel[10];
emp1=new tel[10];
int k,t;
Scanner sc=new Scanner(System.in); // Scanner 要大寫
System.out.println("請進(jìn)行操作選擇");
while(true) // boolean
{System.out.println("請選擇操作碼:\n0:exit\t1:輸入\t2:輸出\t3:刪除\t4:查找!");
k=sc.nextInt();
if(k4||k0)
{System.out.println("輸入操作碼有誤,請重新輸入!");
continue;}
else
{switch(k)
{case 0: break; // 去掉exit
case 1:shuru(emp,10); break;
case 2:shuchu(emp,10); break;
case 3:t=shanchu(emp,10,"李明");
if(t==10) System.out.println("沒有找到指定條件記錄,無法刪除");
else {System.out.println("刪除后結(jié)果為:"); shuchu(emp,t);} break;
case 4:t=search(emp,10,emp1,"計算機(jī)系");
if(t==0) System.out.println("沒有找到指定條件記錄!");
else {System.out.println("找到的記錄集合為:");shuchu(emp1,t);} break; //System
}
}
}
}
static void shuru(tel x[],int y)
{BufferedReader buf;
buf=new BufferedReader(new InputStreamReader(System.in));
Scanner sc=new Scanner(System.in); //Scanner
try{
for(int i=0;iy;i++)
{x[i]=new tel();
System.out.println("請輸入第"+(i+1)+"個員工信息"); // println
System.out.print("員工編號:");
x[i].empno=sc.nextInt();
System.out.print("員工姓名:");
x[i].empname=buf.readLine();
System.out.print("員工部門:");
x[i].empdept=buf.readLine();
System.out.print("員工電話號碼:");
x[i].empph=buf.readLine();}
}catch(IOException e){e.printStackTrace();}
}
static void shuchu(tel x[],int y)
{System.out.println("員工電話號碼信息為:");
System.out.println("編號\t姓名\t部門\t電話號碼");
System.out.println("-------------------------------------");
for(int i=0;iy;i++)
{System.out.println(x[i].empno+"\t"+x[i].empname+"\t"+x[i].empdept+"\t"+x[i].empph);
System.out.println("-------------------------------------");}
}
static int shanchu(tel x[],int y,String s)
{int k;
k=y;
for(int i=0;ik;i++)
if(x[i].empname.equals(s))
{for(int j=i;jk-1;j++)
{x[j].empno=x[j+1].empno;
x[j].empname=x[j+1].empname;
x[j].empdept=x[j+1].empdept;
x[j].empph=x[j+1].empph;}
k--;i--;}
return k;
}
static int search(tel x[],int y,tel xx[],String s)
{int k=0;
for(int i=0;iy;i++)
if(x[i].empdept.equals(s))
{xx[k]=new tel();
xx[k].empno=x[i].empno;
xx[k].empname=x[i].empname;
xx[k].empdept=x[i].empdept;
xx[k].empph=x[i].empph;
k++;}
return k;
}
}
文章題目:java面試代碼挑錯 Java常見面試問題
URL網(wǎng)址:http://muchs.cn/article6/hgecig.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設(shè)、品牌網(wǎng)站制作、關(guān)鍵詞優(yōu)化、App開發(fā)、外貿(mào)網(wǎng)站建設(shè)、域名注冊
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)