您好,提問者:

在薩迦等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì) 網(wǎng)站設(shè)計(jì)制作定制網(wǎng)站制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站設(shè)計(jì),成都營銷網(wǎng)站建設(shè),外貿(mào)網(wǎng)站制作,薩迦網(wǎng)站建設(shè)費(fèi)用合理。
write是寫入到了內(nèi)存流中,你要調(diào)用flush()或者close()才刷新流內(nèi)容。
sw.write("美麗新世界");?????
sw.flush();?//或者sw.close();
標(biāo)準(zhǔn)寫法是catch完了finally{try{xx}cxxx{sw.close();}}
你的這個(gè)有點(diǎn)問題,正確的程序應(yīng)該是這樣的:public class Abc{
String s;
public static void main(String[] args){
Abc m=new Abc();
m.go();
}
Abc(){
return "constructor";
}
void go(){
System.out.println(s);
}
}或者也可以這樣寫:public class Abc{
String s;
public static void main(String[] args){
Abc m=new Abc();
m.go();
}
Abc(){
s= "constructor";
}
void go(){
System.out.println(s);
}
}你的錯(cuò)誤主要在Abc是個(gè)構(gòu)造方法,他前面不用帶什么修飾,完全和類名相同就可以了。
代碼問題? 問題挺多我修改了
import java.util.*;
public class Play1 {
Scanner input=new Scanner(System.in);
int humen;
public void humen(){
humen=input.nextInt(); //獲取值要放在humen方法內(nèi)否則不會運(yùn)行的
switch(humen){
case 1:
System.out.println("你出剪刀。");break; //不能省去break否則會可能把所有條件都運(yùn)行
case 2:
System.out.println("你出石頭。");break;
case 3:
System.out.println("你出布。");break;
}
}
}
public class Play2 {
int com;
public void com(){
com=(int)(Math.random()*10%3+1); //隨機(jī)數(shù)獲取方法com方法內(nèi)部否則一個(gè)實(shí)例只生成一次。以后就不會再改變。
switch(com){
case 1:
System.out.println("電腦出剪刀。");break;//break不要漏
case 2:
System.out.println("電腦出石頭。");break;
case 3:
System.out.println("電腦出布。");break;
}
}
}
import java.util.*;
public class Game {
Play1 humen;
Play2 com;
public void initial(){
humen=new Play1();
com=new Play2();
}
public void StartGame(){
String play2="無";
System.out.println("*****************");
System.out.println("****猜拳 開始****");
System.out.println("*****************");
System.out.println("請選擇對方角色,1:劉備 2:孫權(quán) 3:曹操");
Scanner input=new Scanner(System.in);
int AI=input.nextInt();
if(AI==1){
play2="劉備";
}
if(AI==2){
play2="孫權(quán)";
}
if(AI==3){
play2="曹操";
}
System.out.println("請輸入你的名字。");
String play1=input.next();
System.out.println(play2+"VS"+play1);
System.out.println("\n要開始嗎?y/n");
String answer=input.next();
if(answer.equals("n")) //注意大括號范圍把下邊的if(answer.equals("y"))包在大括號內(nèi)了,這樣程序就無法運(yùn)行。會直接退出的,改成else if
System.out.println("結(jié)束游戲。");
else if(answer.equals("y")){
for(int i=0;i=0;i++){
System.out.println("請出拳,1、剪刀 2、石頭 3、布");
humen.humen();
com.com();
if(humen.humen-com.com==1||humen.humen-com.com==-2){
System.out.println("你贏了!");
}
if(humen.humen-com.com==0){
System.out.println("平手!");
}
if(com.com-humen.humen==1||com.com-humen.humen==-2){
System.out.println("你輸了!");
}
System.out.println("是否繼續(xù)下一輪?");
}
}
}
}
public class StartGame {
public static void main(String[]args){
Game initial=new Game();
initial.initial();
initial.StartGame();
}
}
標(biāo)題名稱:java沒有輸出的代碼,在java語言中,如果數(shù)值后沒有字母
文章轉(zhuǎn)載:http://chinadenli.net/article11/dseccdd.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、手機(jī)網(wǎng)站建設(shè)、網(wǎng)站策劃、網(wǎng)站排名、網(wǎng)站制作、網(wǎng)站營銷
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)