How to check if the first-letter of a string is uppercase in Java

2 Answers

0 votes
package javaapplication1;
 
public class JavaApplication1 {
 
    public static void main(String[] args) {
 
        String s = "Java programming language"; 
                
        if (Character.isUpperCase(s.charAt(0)))
            System.out.println("UpperCase");
    }
}
 
 
/*
 
run:
                    
UpperCase
  
*/

 



answered Feb 4, 2017 by avibootz
0 votes
package javaapplication1;
 
public class JavaApplication1 {
 
    public static void main(String[] args) {
 
        String s = "Java programming language"; 
                
        if (Character.isUpperCase(s.codePointAt(0)))
            System.out.println("UpperCase");
    }
}
 
 
/*
 
run:
                    
UpperCase
  
*/

 



answered Feb 4, 2017 by avibootz

Related questions

1 answer 145 views
1 answer 223 views
1 answer 188 views
1 answer 194 views
1 answer 226 views
...