hello everyone, i am a beginner in java programming and i usually look in the internet for the solutions of my homeworks in java for my subject and i encountered this code and i really don't understand how it works so please, can anybody can explain it to me please.... i really need your help now!!! Thanks in advance!!!
public class Anagram { public void anag(String s1, String s2) { if(s1.length() == 0) { System.out.println(s2); } for(int i = 0; i < s1.length(); i++) { anag(s1.substring(0, i) + s1.substring(i+1, s1.length()), s1.charAt(i) + s2); } } public static void main(String[] args) { Anagram ana = new Anagram(); ana.anag("farm", ""); } }