Question: in JAVA why my code is not running Scanner k = new Scanner(System.in); System.out.println(Please enter a string: ); String str = k.nextLine(); System.out.println(Please enter a

in JAVA

why my code is not running

Scanner k = new Scanner(System.in); System.out.println("Please enter a string: "); String str = k.nextLine(); System.out.println("Please enter a character: "); String input = k.nextLine(); char a = input.charAt(0); int count = 0; for(int i= 0;i<= str.length(); i++) { if(str.charAt(i) == a) count ++; } if(count <= 0) System.out.println("Character not found in the string "); else System.out.println("The number of character appears in the string is " + count);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!