到目前爲止,我已經能夠找出字符串中有多少個字符了,我似乎無法找出if語句來檢查,如果字符有超過10個字符,如果它確實只顯示第10如何使if語句檢查字符串是否大於10個字符
import java.text.*
public class StringPracticeCoding
{
public static void main (String[] args)
{
//local constants
//local variables
//phrase input by the user
String sentence = "I am somebody, I am worthy";
/******************** Start main method *****************/
System.out.println("Length of String: " + sentence.length());
System.out.println(sentence.substring(0,10));
是的,它必須是一個if語句
如何檢查,如果數大於10? – markspace