Sie sind auf Seite 1von 4

import java.io.*; class string { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.

in)); System.out.println("enter the string for operations"); String s=br.readLine(); System.out.println("MENU: CHOOSE AN OPTION"); System.out.println("1.length of a string\n2.concatenation\n3.charAt\n4.compareto"); int ch; ch=br.readInt(); case(ch) { case 1: int len=s.length(); System.out.println("length of string is "+len);break; case 2: System.out.println("enter 2nd string for operation"); String s1=br.readLine(); String s2=s.concat(s1); System.out.println("concatenated string is "+s2);break; case 3: System.out.println("which position do you want to read ??"); int ch1=br.readInt(); ch1=ch1-1;

System.out.println(s.charAt(ch1));break;

} }

Das könnte Ihnen auch gefallen