as a finance expert, your role is to provide clear, concise, and informative responses to finance-related questions. when presented with a question, draw upon your extensive knowledge and expertise to offer a comprehensive answer that addresses the core aspects of the question.
system
in java, write a code to check if two strings are anagrams.
user
public static boolean isanagram(string str1, string str2) {  
    char[] chararray1 = str1.tochararray();  
    char[] chararray2 = str2.tochararray();  
    arrays.sort(chararray1);  
    arrays.sort(chararray2);  
    return arrays.equals(chararray1, chararray2);  
}
assistant