checking using equals() method : false
checking using equalsIgnoreCase() method : true
Possible output of the program
checking using equalsIgnoreCase() method : true
Possible output of the program
How to check if two strings are anagrams of each other?
How to do ....
We can say if two strings are an anagram of each other if they contain the same characters but at different orders.
Ex. army & mary
This question requires a good understanding of the Java String class and Java arrays.
How to do ....
We can say if two strings are an anagram of each other if they contain the same characters but at different orders.
Ex. army & mary
This question requires a good understanding of the Java String class and Java arrays.
Java Hyd Team
How to check if two strings are anagrams of each other? How to do .... We can say if two strings are an anagram of each other if they contain the same characters but at different orders. Ex. army & mary This question requires a good understanding of theβ¦
In the above program, the isAnagram() method took two string firstString and secondString as an input parameter.
We are converting these string into the character array.
Also, we are applying the toLowerCase() method to the strings to make sure every character of the char array should be in lower case.
Once we got both the array, we are sorting them using the Arrays.sort() method.
Arrays.sort() method sort the specified array into ascending numerical order.
Finally, we will check if the arrays are equals using Arrays.equals() method.
If they are equal, that means they are an anagram of each other.
If they are not equal, then they are not an anagram of each other.
We are converting these string into the character array.
Also, we are applying the toLowerCase() method to the strings to make sure every character of the char array should be in lower case.
Once we got both the array, we are sorting them using the Arrays.sort() method.
Arrays.sort() method sort the specified array into ascending numerical order.
Finally, we will check if the arrays are equals using Arrays.equals() method.
If they are equal, that means they are an anagram of each other.
If they are not equal, then they are not an anagram of each other.
How to reverse a string in Java without using the reverse method?
This is the common question asked in the java interviews. We know, we can easily reverse the java string using the reverse() method of the StringBuilder class.
You will be asked to reverse the string without using any pre-defined library reverse method.
This is the common question asked in the java interviews. We know, we can easily reverse the java string using the reverse() method of the StringBuilder class.
You will be asked to reverse the string without using any pre-defined library reverse method.
Java Hyd Team
How to reverse a string in Java without using the reverse method? This is the common question asked in the java interviews. We know, we can easily reverse the java string using the reverse() method of the StringBuilder class. You will be asked to reverseβ¦
In the first method, we are initializing an empty string variable, reversedString.
You can use the charAt() method of the String class to get the character at any particular index of the string.
We are getting the characters of the inputString one by one in reverse order and appending it to the reversedString.
Finally, we are returning the reversedString.
Q3.)
In the second method, we are converting the inputString to the characters array using the toCharArray() method of the String class.
Once we got the array, we are appending the characters from the characters array stringCharArray to reversedString one by one in reverse order.
And finally, we are returning the reversedString.
You can use the charAt() method of the String class to get the character at any particular index of the string.
We are getting the characters of the inputString one by one in reverse order and appending it to the reversedString.
Finally, we are returning the reversedString.
Q3.)
In the second method, we are converting the inputString to the characters array using the toCharArray() method of the String class.
Once we got the array, we are appending the characters from the characters array stringCharArray to reversedString one by one in reverse order.
And finally, we are returning the reversedString.
Java Hyd Team pinned Β«DO YOU GUY'S NEED SOME MORE HAND WRITTEN POINT TO POINT NOTES ??Β»
Java Hyd Team
DO YOU GUY'S NEED SOME MORE HAND WRITTEN POINT TO POINT NOTES ??
Please vote it takes efforts to share notes so point to point
If you like the way we describe if you really think this support matters do share us with your friends let's grow
Only one response i have rcvd yet anyone else wanna share or we can close accepting n sharing these questions
Java Hyd Team
DO YOU GUY'S NEED SOME MORE HAND WRITTEN POINT TO POINT NOTES ??
Only 8 of 28 need these things rest can leave this channel ππ