My code compiles successfully but doesn't run why??
What problem whatsoever is with the syntax?????
import java.util.Scanner;
public class uppercase{
public static void main(String args){
Scanner in=new Scanner(System.in);
System.out.println("Enter string:");
String str=in.nextLine();
for(int i=0;i<str.length();i++)
{if(i!=str.length()-1&&str.charAt(i+1)>='a'&&str.charAt(i+1)<='z'&&str.charAt(i)==' ')
{ str = Character.toUpperCase(str.charAt(i)) + str.substring(i+1);
}
}
if(str.charAt(0)>='a'&&str.charAt(0)<='z')
str = Character.toUpperCase(str.charAt(0)) + str.substring(1);
System.out.print(str);
}
}