Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

I need help please send me reply:
Write a program "if given a string like 'HAT', the
combination's returned should be like ATH,THA,TAH in java"?

Answer Posted / g.s.reddy

public class Example {
public static void main(String args[]) throws Exception {
String input = "HAT";
showPattern("", input);
}
public static void showPattern(String st, String chars) {
if (chars.length() <= 1)
System.out.println(st + chars);
else
for (int i = 0; i < chars.length(); i++) {

try {
String newString = chars.substring(0, i)
+ chars.substring(i + 1);
showPattern(st + chars.charAt(i),newString);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which are the two subclasses under exception class?

1093


How arrays are stored in memory in java?

980


Is set ordered?

978


How many types of design patterns are there?

1103


What is the static variable?

1122


Why does it take so much time to access an applet having swing components the first time?

1925


What methods are used to get and set the text label displayed by a button object?

1017


Define locale.

1038


Does string is thread-safe in java?

1089


Why there are some null interface in java? What does it mean?

1127


how to one war file class to another war file class?

2077


What are the 5 types of research methods?

1141


Difference between Preemptive scheduling vs. Time slicing?

1021


Is class is a data type?

1077


What is the purpose of assert keyword used in jdk1.4.x?

1067