?? spaces.java
字號:
import java.io.*;
import javagently.*;
class Spaces {
/* Removing spaces program by J M Bishop Dec 1997
* ----------------------- Java 1.1
*
* Replaces double spaces by single.
* Illustrates use of string handling methods.
*/
public static void main (String args []) throws IOException {
System.out.println("Program to convert double spaces");
System.out.println("to single ones.");
Stream fin = new Stream (System.in);
String s = "";
int spaceAt, startingFrom;
try {
while (true) {
s = fin.readLine();
if (s==null) throw new EOFException();
startingFrom = 0;
while (true) {
spaceAt = s.indexOf(" ",startingFrom);
if (spaceAt==-1) break;
else if (spaceAt==0)
s = s.substring(1,s.length());
else s = s.substring(0,spaceAt)+" "
+ s.substring(spaceAt+2,s.length());
startingFrom = spaceAt+2;
}
System.out.println(s);
}
}
catch (EOFException e) {}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -