string cannot be resolved to a type

14,021

String is capitalized in Java. You cannot use lowercase string. (That's C#)

Side question:
How is the following compiling at all?

template.composeFormLetter(Sean, Colbert, God);
Share:
14,021

Related videos on Youtube

chief
Author by

chief

Updated on June 04, 2022

Comments

  • chief
    chief almost 2 years

    I am getting a "string cannot be resolved to a type" error in my code.

    public class Main {
    
    
     public static void main(String[] args) {
      // TODO Auto-generated method stub
      FormLetter template;
      template = new FormLetter();
      template.print();
      template.composeFormLetter(Sean, Colbert, God);
      template.print();
    
     }
    
    }
    
    class FormLetter
     {
      public void print(){
        System.out.println(to + candidate + from);
    
      }  
    
      public void composeFormLetter(string t, string c, string f){
    
       to = t;
       candidate = c; 
       from = f;
      } 
       private string to;
       private string candidate;
       private string from;
    
      }
    
    • In silico
      In silico over 13 years
      For future reference, be sure to post the entire compiler error message in your question if present, to make it easier to pinpoint what's wrong.
  • chief
    chief over 13 years
    Ok, I corrected the string issue. template.composeFormLetter(Sean, Colbert, God); is leaving an error: Multiple markers at this line - God cannot be resolved - Colbert cannot be resolved - Sean cannot be resolved
  • Stephen C
    Stephen C over 13 years
    @chief - String literals are supposed to have double quotes around them. (Side answer - it is not ...)
  • jjnguy
    jjnguy over 13 years
    @chief, "God", "Sean", "Colbert" You need to put Strings inside of quotation marks.
  • chief
    chief over 13 years
    Alright in the console it returns: nullnullnull and then god colbert sean.
  • jjnguy
    jjnguy over 13 years
    @chief, that's what it's supposed to do?
  • chief
    chief over 13 years
    god colbert sean - is what I was expecting. I am not sure why I am also getting nullnullnull first.
  • jjnguy
    jjnguy over 13 years
    @chief, Well, you call template.print() twice. The first time all of the variables are null, and the second time they have values.
  • jjnguy
    jjnguy over 13 years
    @chief, also, you should check the green checkmark next to my answer to show that it is the one that helped you answer your question.