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

What is jpa specification?

917


How do you escape a string?

910


Can arraylist hold different types java?

922


Difference between keyword and identifier.

971


What is bytecode verifier?

877


How do you calculate square roots?

1096


Explain listiterator and methods in listiterator?

956


Which variables are stored in heap?

972


Is java a software?

891


What is the gregoriancalendar class in java programming?

970


Define jit compiler?

1054


What is numeric function?

947


Can you declare the main method as final?

955


What is oop principle in java?

1048


How many characters is 2 bytes?

937