Anagrams In Java ISC ICSE CBSE Class 12

import java.util.*;
class Anagram{
    public static void main(){
        String s;
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter a word");
        s=sc.next();
        Anagram ob=new Anagram();
        ob.display("",s);
    }
    public void display(String p,String w){
        if(w.length()<=1)
        System.out.println(p+w);
        else{
            for(int i=0;i<w.length();i++){
            String a=w.substring(i,i+1);
            String b=w.substring(0,i);
            String c=w.substring(i+1);
            display(p+a,b+c);
        }
    }
}
}

Comments

  1. "Ziyyara’s ISC tutor offers one-to-one online home tuition for ISC Board students.They implement pedagogy teaching methods while delivering online tuition classes."
    Visit On:- isc online tuition
    Phone no - +91-9654271931

    ReplyDelete

Post a Comment

Popular posts from this blog

Sort Boundary Elements Of A Matrix

Lucky Number In Java ISC

Program to fill a square matrix of size ‘n*n” in a circular fashion (clockwise) with natural numbers from 1 to n*n, taking ‘n’ as input.