I am getting two failed test cases out of 6. Kindly help in pointing out what may be wrong

import java.util.*;
public class readthis {

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s;
	s = sc.next();
	if(s.length()==1) {
		if(Character.isUpperCase(s.charAt(0))) {
			System.out.println(s);
		}
	}
		
	for(int i=0;i<s.length();i++) {
		
		if(Character.isUpperCase(s.charAt(i))) {
			for(int j=i+1;j<s.length();j++) {
				if(Character.isUpperCase(s.charAt(j))) {
					System.out.println(s.substring(i,j));
					j=s.length();
				
				}
				else if (j==s.length()-1) {
					System.out.println(s.substring(i,j+1));
				}
			}
		}
	}

}

}

there is a little error in your logic consider string str=“eBay” the output should be
e
Bay
but your code is not printing e…it is not necessary that camel case begins with upper case…

Okay, i understood. I added a small thing to take care of that issue. Still then I am getting two wrong answers for two testcases.
import java.util.*;
public class readthis {

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String s;
	s = sc.next();
	if(s.length()==1) {
		System.out.println(s);
	}
	if(Character.isLowerCase(s.charAt(0))) {
		for(int k=1;k<s.length();k++) {
			if(Character.isUpperCase(s.charAt(k))) {
				System.out.println(s.substring(0,k));
				break;
			}
		}
	}
		
	for(int i=0;i<s.length();i++) {
		
		if(Character.isUpperCase(s.charAt(i))) {
			//System.out.println(s.substring(0,i));
			for(int j=i+1;j<s.length();j++) {
				if(Character.isUpperCase(s.charAt(j))) {
					System.out.println(s.substring(i,j));
					j=s.length();
				
				}
				else if (j==s.length()-1) {
					System.out.println(s.substring(i,j+1));
				}
			}
		}
	}

}

}

you need to take care of some more edge cases like:
1)if all the characters are lower case then it should print that lower case word so add a condition in your first for loop that if you reach the end of string you need to print the substring(0,s.length())
2)if there is a capital letter at the end of the string it will not print that letter…make the changes in second for loop(after finishing your first for loop add a condition that if i==s.length() then print s.charAt(i) )

Hi Ashish

As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.