Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


VIVEK RANA
StringIndexOutOfBoundException problem, What is mean in this code | first.charAt(i)) |
0 Answer(s)      a year and 11 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); } } } } }`


Advertisement
View Answers

Related Tutorials/Questions & Answers:
 

 

 

DMCA.com