Every time I write " my compiler assumes I am trying to write a String. Instead I want my method to tell me if the incoming string starts with a double quote "" Ex:
String n;
if(n==n.startsWith(" " " ));
doesn't work
Any suggestions??
Every time I write " my compiler assumes I am trying to write a String. Instead I want my method to tell me if the incoming string starts with a double quote "" Ex:
String n;
if(n==n.startsWith(" " " ));
doesn't work
Any suggestions??
 
    
     
    
    You have to escape double quotes in string!
If you do it like this: " " ", string ends on second quotation mark. If in Java, you code should be like:
String n;
if(n.startsWith("\""))
{
    // execute if true
}
Since you are matching just first character, you don't need to use such sophisticated tool as regular expressions:
String n;
if (n.charAt(0)=="\"")
{
    // execute if true
}
BUT. You should make sure if string is not empty. Just for safety:
String n;
    if (n.getText()!=null 
        && !n.getText().isEmpty() 
        && n.charAt(0)=="\"")
    {
        // execute if true
    }
PS: space is a character.
PSS: flagged as dublicate.
