StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |

StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |

import java.io.*;

public class Sort{

public static void main(String[]args)throws IOException{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter the first String");

String first=br.readLine();

System.out.println("Enter the second String");

String second = br.readLine();

int count1=0,count2=0,i;

for(int c=0;c<128;c++){

for( i=0;i<11-1;i++){

if((byte)c==(byte)first.charAt(i))

{ count1++;

}

}

for(i=0;i<12-1;i++){

if((byte)c==(byte)second.charAt(i)) {

count2++;

}

}

if(count1>count2){

for(i=1;i<=count1;i++)

{

System.out.println((char)c); } }

else{

for(i=1;i<=count2;i++) {

System.out.println((char)c); } } } } }`

View Answers









Related Tutorials/Questions & Answers:

Ads