import java.io.*;
public class GetUserInput {
public static void main (String[] args) {
System.out.print("Enter your name and press Enter: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String name = null;
try {
name = br.readLine();
} catch (IOException e) {
System.out.println("Error!");
System.exit(1);
}
System.out.println("Your name is " + name);
}
}
Showing posts with label string. Show all posts
Showing posts with label string. Show all posts
Saturday, September 25, 2010
Friday, September 24, 2010
string reverse
this pgm ll get a string form u and displays the string length then reverse string is display
import java.util.Scanner;
public class reverse_string{public static void main(String args[]){
String s;
Scanner in=new Scanner(System.in);
System.out.println("enter the string");s=in.nextLine();
int len=s.length();
System.out.println("length of string is"+len);int i;
while(len>0){
char yo=s.charAt(len-1);System.out.print(yo);len=len-1;}
}}
import java.util.Scanner;
public class reverse_string{public static void main(String args[]){
String s;
Scanner in=new Scanner(System.in);
System.out.println("enter the string");s=in.nextLine();
int len=s.length();
System.out.println("length of string is"+len);int i;
while(len>0){
char yo=s.charAt(len-1);System.out.print(yo);len=len-1;}
}}
Subscribe to:
Posts (Atom)