我只想打印出来 来自String的Int和来自字符串的前2个字符也是如此,我怎么能这样做,请帮助我谢谢!!
假设,
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class match1 {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String address = "1234 main street";
}
}
输出应该是:
1234 ma
我该怎么做才能帮助我!!谢谢!
答案 0 :(得分:2)
String address = "1234 main street";
String[] tokens = address.split(" ");
System.out.println(tokens[0]+" "+tokens[1].substring(0,2));