I am trying to design a program that compares two strings for the same character in the same positions but same error keeps popping up help please : Length does not matter in this regard so for example:

string 1:    "hi--there-you."    "-15-389"    "criminal-plan"    "abc"

string 2:    "12--(134)-7539"    "-xy-zzy"    "(206)555-1384"    "9.8"

Both pairs would return True. My problem is that when I try to compile the code below I get the following error:

Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.lang.String.charAt(Unknown Source)
	at SameDashes.sameDashes(SameDashes.java:20)
	at SameDashes.main(SameDashes.java:4)


       public static boolean sameDashes(String a, String b){
		int minlength = Math.min(a.length(), b.length());
		String smallstring="";
		String bigstring="";
		if(a.length()== minlength){
			smallstring = a;
			bigstring = b;
		}
		else {
			smallstring = b;
			bigstring =a;
		}
		int counter = 0;
		do {
			if(bigstring.charAt(smallstring.indexOf('-',counter))!='-'){
				return false;
			}
			else if(bigstring.indexOf('-',counter)!= -1){
				return false;
			}
			counter++;
			
		}while(counter<= bigstring.length());
		return true;
	}