I was trying to make a method that returns true if given "Strings" are anagrams. unfortunately i cant even test it and i don know what is wrong. The markers at left says:
Multiple markers at this line - Breakpoint:Test - Duplicate modifier for the type Test
Here is the source code:
package zajecia19;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashMap;
public
public class Test {
public static boolean Anagraamy(String s1, String s2) {
if (s1.length() != s2.length()) {
return false;
}
HashMap<Character, Integer> map = new HashMap<>();
for (int i = 0; i < s1.length(); i++) {
if (map.containsKey(s1.charAt(i))) {
map.put(s1.charAt(i), map.get(s1.charAt(i)) + 1);
} else {
map.put(s1.charAt(i), 1);
}
if (map.containsKey(s2.charAt(i))) {
map.put(s2.charAt(i), map.get(s2.charAt(i)) - 1);
} else {
map.put(s2.charAt(i), -1);
}
}
for( Integer value: map.values()){
if(value != 0 ){
return false;
}
}
return true;
}
public static void main(String[] args) {
try (BufferedReader br = new BufferedReader(new FileReader("slowa2"))) {
System.out.println( Anagraamy("abba", "babb"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
Because you have
public
public
there.
The obvious way to fix that: remove the first one. And next time: pay attention to what the compiler is trying to tell you.