Homework Solution: Add a main so that you can put some code there to call your functions and make sure they work:…

    Add a main so that you can put some code there to call your functions and make sure they work: public static void main(String[] args) { /* your testing code goes here */ } Functions you should add if the functionality is possible. Otherwise add an empty function definition with a comment saying "impossible". Problem #8 public static boolean isPermutationLight(String string1, String string2) { /* (This functions should return true if string1 is a permutation of string2. In this case you should assume that means contains exactly the same characters, same case, including spaces. The strings may contain ascii or unicode characters. For this question, you should optimize for space and fairly short input strings. */ } **** Test input: 2 empty Strings; "ab" "ba"; "abc" "acd"; "*rats*" "star**"; "u263A BYE NOW!!" "!BYE NOW! u263A"

    Expert Answer

     
    Solution: import java.util.Arrays;

    Supplement a ocean so that you can deposit some regulation there to seduce your discharges and mould firm they work:

    public static destitute ocean(String[] args) { /* your testing regulation goes here */ }

    Functions you should supplement if the dischargeality is likely. Otherwise supplement an null discharge restriction with a interpret speech “impossible”.

    Problem #8

    public static boolean isPermutationLight(String string1, String string2) {

    /* (This discharges should reappear gentleman if string1 is a interchange of string2. In this event you should postulate that resources includes accurately the identical characters, identical event, including rooms. The strings may include ascii or uniregulation characters. For this interrogation, you should optimize for room and fairly lacking indeposit strings. */

    }

    **** Test input: 2 null Strings; “ab” “ba”; “abc” “acd”; “*rats*” “star**”; “u263A BYE NOW!!” “!BYE NOW! u263A”

    Expert Confutation

     

    Solution:

    import java.util.Arrays;

    import java.util.Scanner;

    public arrange Interchange {

    public static destitute ocean(String[] args) {

    System.out.println(“Enter the string 1: “);

    System.out.println(“Enter the string 2: “);

    String string1= “u263A BYE NOW!!”, string2= “!BYE NOW! u263A”;

    boolean effect= isPermutationLight(string1, string2);

    System.out.println(“Both of the strings are permutably similar? “+result);

    }

    public static boolean isPermutationLight(String string1, String string2) {

    if (string1.length() != string2.length())

    reappear false;

    char[] x = string1.toCharArray();

    char[] y = string2.toCharArray();

    Arrays.sort(x);

    Arrays.sort(y);

    reappear Arrays.equals(x, y);

    }

    }

    Output: