Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Strings with same letters with reps
//'main' method must be in a class 'Rextester'. //openjdk version '11.0.5' import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { String str1 ="Cancer"; String str2="runner"; if(str1.length()!=str2.length()){ System.out.println("Not Same"); return; } str1=str1.toUpperCase(); str2=str2.toUpperCase(); ArrayList<Character> arr1=new ArrayList<>(); ArrayList<Character> arr2=new ArrayList<>(); for(int i=0;i<str1.length();i++){ arr1.add(str1.charAt(i)); arr2.add(str2.charAt(i)); } Collections.sort(arr1); Collections.sort(arr2); if(arr1.equals(arr2)){ System.out.println("Same"); }else{ System.out.println("Not Same"); } } }
run
|
edit
|
history
|
help
0
heeeeell
Java OOP
1a
javaHashTable
Apple Banana Pear question
Sum of ODD and EVEN numbers in an array
test
Test.java
Hello World
Problem: on_off