내게 아플 수 있습니다. 이걸로 나를 도울 수 있습니까? 내 문제는 내 Java 프로그램과 그것의 인덱스에 공백을 식별하는 것입니다하지만 색인 (JAVA)를 식별하는 방법을 모르겠다. 내 코드 heres :색인 식별 (자바)
import java.util.*;
public class CountSpaces
{
public static void main (String[] args)
{
System.out.print ("Enter a sentence or phrase: ");
Scanner input=new Scanner(System.in);
String str=input.nextLine();
int count = 0;
int limit = str.length();
for(int i = 0; i < limit; ++i)
{
if(Character.isWhitespace(str.charAt(i)))
{
++count;
}
}
감사합니다.
'i'는 색인입니다. –