public static void main(String[] args) {

目前成都創(chuàng)新互聯(lián)已為上千多家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)頁空間、網(wǎng)站托管運(yùn)營、企業(yè)網(wǎng)站設(shè)計、西雙版納網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
System.out.println("你好");
}
public static void main(String[] args) {
System.out.println("\"你好\",\"1+2=3\"");
}
你的主函數(shù)沒有錯誤,你應(yīng)該恢復(fù)主函數(shù)原來的樣子public static void main(String[] args){
User user=new User();
user.setId(1001);
user.setName("user");
user.setStuNum("1001");
new TicketBooker(user);
}你的Java程序是在109行JCB_Year.setSelectedIndex(date.getYear()+1900-Integer.parseInt(arrayYear[0]));這句出問題了,因?yàn)榻衲晔?018年,date.getYear()+1900=2018,2018-2014=4,JCB_Year.setSelectedIndex(4);而你的private JComboBox JCB_Year=new JComboBox(arrayYear);arrayYear是只定義了三個字符串的數(shù)組
private static final String arrayYear[]={"2014","2015","2016"};所以造成JComboBox下標(biāo)Index越界,本來下標(biāo)只有0到2你訪問到了4.改正辦法把a(bǔ)rrayYear數(shù)組加兩個元素,把private static final String arrayYear[]={"2014","2015","2016"};改成private static final String arrayYear[]={"2014","2015","2016","2017","2018"};就沒問題了.注意,arrayYear數(shù)組 2019年還需要加"2019",2020年還需要加"2020"
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
public class Io{
public static void main(String [] s){
File filename = new File("F:\\suncity.txt");
String filein="你好!";
RandomAccessFile mm = null;
try {
mm = new RandomAccessFile(filename,"rw");
mm.writeBytes(filein);
} catch (IOException e1) {
// TODO 自動生成 catch 塊
e1.printStackTrace();
} finally{
if(mm!=null){
try {
mm.close();
} catch (IOException e2) {
// TODO 自動生成 catch 塊
e2.printStackTrace();
}
}
}
}
}
題目的意思
就是根據(jù)輸入的不一樣, 進(jìn)行判斷和輸出
例一
import?java.util.Scanner;
public?class?Test?{
public?static?void?main(String[]?args)?{
Scanner?input?=?new?Scanner(System.in);
System.out.println("請輸入你的性別?男/女");
String?sex?=?input.nextLine();//讀取輸入的一行
if(sex.equals("男")){//分情況輸出
System.out.println("帥哥你好");
}else?if(sex.equals("女")){
System.out.println("美女你好");
}else{
System.out.println("你好");
}
}
}
輸出
請輸入你的性別?男/女
男
帥哥你好
例二:
import?java.util.Scanner;
public?class?PrintDemo?{
public?static?void?main(String[]?args)?{
String[]?enNum?=?{"zero","one","two","three","four","five"};
System.out.println("請輸入0~5的數(shù)字.系統(tǒng)轉(zhuǎn)換成英文并輸出");
Scanner?input?=?new?Scanner(System.in);//控制臺輸入
while(true){
String?line?=?input.nextLine();
if(line.equals("exit")){
System.out.println("系統(tǒng)退出");
System.exit(0);
}else{
int?x?=?Integer.parseInt(line);
System.out.println("數(shù)字"+x+"轉(zhuǎn)成英語:"+enNum[x]);//控制臺輸出
}
}
}
}
運(yùn)行測試
請輸入0~5的數(shù)字.系統(tǒng)轉(zhuǎn)換成英文并輸出
2
數(shù)字2轉(zhuǎn)成英語:two
3
數(shù)字3轉(zhuǎn)成英語:three
exit
系統(tǒng)退出
當(dāng)前文章:你好java代碼,java語言代碼
文章分享:http://chinadenli.net/article24/hshice.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供關(guān)鍵詞優(yōu)化、網(wǎng)站設(shè)計、網(wǎng)站維護(hù)、品牌網(wǎng)站設(shè)計、微信公眾號、App設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)