1. Find if a string is an anagram of another
public class anagram {
public static void main(String[] args) {
// TODO Auto-generated method stub
boolean isAnagram=false;
String str1="armys";
String str2="marsy";
char[] c1= str1.toCharArray();
char[] c2= str2.toCharArray();
if(str1.length()!= str2.length()){
isAnagram=false;
}else{
Arrays.sort(c1);
Arrays.sort(c2);
for(int i=0;i<c1.length;i++){
if(c1[i] ==c2[i]){
isAnagram=true;
}
}
}
if(isAnagram){
System.out.println("Is anagram");
}else{
System.out.println("Not anagram");
}
}
}
2. Write a program that finds out 2 numbers adds up to a value java
public class sumOf {
public static void main(String[] args) {
// TODO Auto-generated method stub
int n=5;
int[] arr= new int[n];
for (int i=1; i<=n;i++){
arr[i-1]=i;
}
for(int i=0;i<arr.length;i++){
for(int j=0;j<arr.length;j++ ){
int sum=arr[i]+arr[j];
if(sum == n){
System.out.println("Numbers are "+ arr[i] + " " + arr[j]);
}
}
}
}
}
Great post. Needed to write simple word that Thanks for suggestions. Keep it up!
ReplyDeleteBest Data Science Online Training Institute In Hyderabad | Online Data Science Training
Data Science Online Training Institute In Hyderabad
Data science online training in hyderabad
Best data science training in hyderabad
Best selenium online training institute `
ReplyDeletehi, nice information is given in this blog. Thanks for sharing this type of information, it is so useful for me. nice work keep it up. best sap simple finance online training institute in hyderabad
ReplyDeleteThank for sharing this information
ReplyDeleteselenium training centers in Marathahalli
best software testing training institutes in Marathahalli with placements
automation testing courses in Marathahalli
selenium testing course in Marathahalli
software testing institutes in Marathahalli
selenium training in Marathahalli
best selenium training in Marathahalli
selenium course in Marathahalli
Great blog...
ReplyDeleteselenium training centers in Bangalore
best software testing training institutes in Bangalore with placements
automation testing courses in Bangalore
selenium testing course in Bangalore
software testing institutes in Bangalore
selenium training in Bangalore
best selenium training in Bangalore
selenium course in Bangalore