鍵盤輸入我有一個轉換降價字符串爲HTML的代碼:轉換字符串;在Java中
public static String convert(String str) {
if (str.equals("# "))
return " ";
if (str.matches("#+.+")) {
int n = str.length() - str.replaceFirst("#+", "").length();
return "<h" + n + ">" + str.substring(n) + "<h" + n + ">";
}
return str;
}
我想知道的是如何讓這個類來獲取從鍵盤輸入的字符串?
我在convert方法裏面還是在main裏寫這個? –
你會把它放在'main'中。 – Reimeus
非常有幫助。非常感謝 –