Alternate Method 1 :Write a program to find anagram or two words of same letter

import java.util.*; public class Main{ public static void main (String[] args) { Scanner sc = new Scanner(; String; String; String word1=Main.checker(first); String word2=Main.checker(secound); if(word1.equals(word2)){ System.out.println("Same"); }else{ System.out.println("Different"); } } public static String checker(String word){ char arr[]=word.toCharArray(); Arrays.sort(arr); int index=0; for(int i=0;i<arr.length;i++){ int j; for(j=0;j<i;j++){ if(arr[j]==arr[i]){ break; } } if(i==j){ arr[index++]=arr[i]; } } char arr1[]=Arrays.copyOf(arr,index); String newword= new String(arr1); return newword; } }