package study;
import java.util.Scanner;
public class NameUse{
public static void main (String[] args){
System.out.println("Please enter your name:");
Name test= new Name();
System.out.println("Your Name is "+test.toString()+"!");
}
}
class Name
{ Scanner keyboard=new Scanner(System.in);
private String firstname =keyboard.next();
private String lastname =keyboard.next();
firstname=firstname.toLowerCase();//******************************1
lastname=lastname.toLowerCase();//********************************2
public void setFirstName(String firstname)
{this.firstname = firstname;
}
public String getFirstName()
{return this.firstname;
}
public void setLastrName(String lastname)
{this.lastname = lastname;
}
public String getLastName()
{return this.lastname;
}
String fs,ls,fn,ln,fl,ll;
public String toString(){
fs=firstname.substring(1,2);
fs=fs.toUpperCase();
ls=lastname.substring(1,2);
ls=ls.toUpperCase();
fn=firstname.substring(2);
ln=lastname.substring(2);
fl=fs+fn+firstname.substring(0,1)+"ay";
ll=ls+ln+lastname.substring(0,1)+"ay";
return fl+" "+ll;
}
}
为什么在编译时1,2处发生'需要标识符'错误