Hello everyone,
I am currently learning Java. I find it very hard to use string variable. Does string variables need to be declared differently?
Let me explain more:
I have a program(in blueJ) which reads a name and returns it.
public class ReadName
{
// instance variables - replace the example below with your own
private String name1;
/**
* Constructor for objects of class ReadName
*/
public ReadName(String nameT)
{
name1= nameT;
}
public String getName()
{
return name1;
}
}
When I try to input a name, I get "Error: cannot find symbol -variable...."
When I do this with intergers it works perfectly. Please tell me what I am doing wrong?