public class stringbuffersexp1 {
public static void main(String[] args) throws IOException {
StringBuffer sb=new StringBuffer();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter surname:");
String sur=br.readLine();
System.out.println("Enter middle name:");
String midname=br.readLine();
System.out.println("Enter last name:");
String lastname=br.readLine();
sb.append(sur);
sb.append(midname);
System.out.println("name is:"+sb);
sb.append(lastname);
System.out.println("full name is:"+sb);
int n=sb.length();
System.out.println("Length of Full Name is:"+n);
}
}
public static void main(String[] args) throws IOException {
StringBuffer sb=new StringBuffer();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter surname:");
String sur=br.readLine();
System.out.println("Enter middle name:");
String midname=br.readLine();
System.out.println("Enter last name:");
String lastname=br.readLine();
sb.append(sur);
sb.append(midname);
System.out.println("name is:"+sb);
sb.append(lastname);
System.out.println("full name is:"+sb);
int n=sb.length();
System.out.println("Length of Full Name is:"+n);
}
}
Output:
Enter surname:
s
Enter middle name:
john
Enter last name:
henry
name is:sjohn
full name is:sjohnhenry
Length of Full Name is:10
No comments:
Post a Comment