Home Answers Viewqa Java-Beginners StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |

 
 


VIVEK RANA
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |
0 Answer(s)      9 months ago
Posted in : Java Beginners

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 Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.