Can u read this problem

Hello can you find the bug in my code, i believe my code and logic is correct.

Please post your code

package String; import java.util.*; public class CanYouReadThis { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); int count=0; for(int i=0;i<str.length();i++) { if(Character.isUpperCase(str.charAt(i) ) ) { count++; } } System.out.println(“There are " + count + " words in the string.”); } }

What are you printing out ? Have you even read the question? I suggest you read the probleem again, especially what you have to output

I am not able to submit the code, what’s is that technical issue, is this because of collaborative mode.

import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.nextLine(); String[] str_array= new String[1000]; int k=0; int i=0; for( i=0;i<str.length()-1;i++) { if(Character.isUpperCase(str.charAt(i))) { for(int j=i+1;j<str.length();j++) { if(Character.isUpperCase(str.charAt(j) ) ) { str_array[k++]= str.substring(i, j); break; } if(j==str.length()-1) { str_array[k++]=str.substring(i, str.length()); } } } } if(Character.isUpperCase(str.charAt(str.length()-1))) { str_array[k]= str.substring(str.length()-1,str.length()); } for(String chk : str_array ) { if(chk != null) System.out.println(chk); } } }

The code seems fine to me. What error are you getting on submitting ?

@pradeep.mahato.cs.2015,
I see that you have submitted your code and got a correct answer. Do you have any other doubt?

earlier there was an technical issue , after few hours it submitted.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.