Code not working here

Maam when I try to run this code here it shows indexOutOfBound Exception whereas it is working properly in eclipse .

Please help

please share your code after saving it on ide.codingblocks.com

Scanner scanner = new Scanner(System.in);
String str = scanner.nextLine();

		duplicateChar(str,"");
    }
	public static void duplicateChar(String str,String result) {
			if(str.length()==0) {
				System.out.println(result);
				return;
			}
			char ch = str.charAt(0);
			String ros = str.substring(1);
     		if(ros=="") {
     			duplicateChar(ros,result+ch);
     		}else if(ch==ros.charAt(0)) {
				String val = ros.substring(1);
				duplicateChar(val,result+ch);
			} else {
				duplicateChar(ros,result+ch);
			}
	
	}
}