标题:java 问题求助
只看楼主
patricknb
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2007-9-21
 问题点数:0 回复次数:0 
java 问题求助

我是新人,刚刚开始学java。现在在做 hangman game
我中文表达的可能不太好,我现在在滑铁卢大学学computer science,一些java 中文的术语不太清楚。。。希望大家能明白我说的意思就行。~

想问一下高手,
假设我输入了一个字母 String n = a ;
System.out.println ("The letter "+ n + " occurs at the following locations in the word: " + comp.whereIsLetterInWord(n));
String theWordis = comp.whereIsLetterInWord(n);
System.out.println ("The word is: " + theWordis );

输出:

Enter a letter: a
The letter 'a' occurs at the following locations in the word: _____a__
The word is: _____a__

这个是没有问题的,但是如果我再输入一个r的话
输出:
Enter a letter: r
The letter 'a' occurs at the following locations in the word: __r_____
The word is: __r_____

我如何让我输入r之后显示如下:

Enter a letter: r
The letter 'r' occurs at the following locations in the word: __r_____
The word is: __r__a__

搜索更多相关主题的帖子: java 
2007-10-04 00:46



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-174927-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.353331 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved