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"?

Answers were Sorted based on User's Feedback



I need help please send me reply: Write a program "if given a string like 'HAT', the..

Answer / 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

I need help please send me reply: Write a program "if given a string like 'HAT', the..

Answer / sathish.pk

public static void main( String[] args )
{

/* you give any String */

String myString="HAT";

char[] characters=new char[3];

for(int i=0;i<1;i++)
{

for(int j=0;j<=2;j++)
{
/* getting each character from above string(myString)*/

characters[j]=myString.charAt(j);
}

/*print each character according to our output*/

System.out.println(characters[i+1]+""+characters[i]+""+characters[i+2]);

System.out.println(characters[i+1]+""+characters[i+2]+""+characters[i]);

System.out.println(characters[i]+""+characters[i+2]+""+characters[i+1]);

System.out.println(characters[i+2]+""+characters[i+1]+""+characters[i]);

System.out.println(characters[i+2]+""+characters[i]+""+characters[i+1]);

}


}

Is This Answer Correct ?    2 Yes 1 No

I need help please send me reply: Write a program "if given a string like 'HAT', the..

Answer / sudhir

it is same as pallindrome ;
take 2 string or character and and exchange the first and
last location at every loop condition.

Is This Answer Correct ?    1 Yes 0 No

I need help please send me reply: Write a program "if given a string like 'HAT', the..

Answer / nijamuddin

Class Help
{
Public stattic void main(String args[])
string s;
if(s=="HAT")
{
System.out.println("ATH, Tha,tah";
}
}

Is This Answer Correct ?    3 Yes 29 No

Post New Answer

More Core Java Interview Questions

What is class and its types?

0 Answers  


I don’t want my class to be inherited by any other class. What should I do?

0 Answers  


What is the use of arraylist in java?

0 Answers  


whst is encapsulation?when u encpsulate actually while devoloping code?

7 Answers   Amdocs, MGL,


Why can't you declare a class as protected?

0 Answers  


Java support what type of parameter passing ?

7 Answers   Wipro,


What are the properties of thread?

0 Answers  


Can static methods access instance variables in java?

0 Answers  


What package is math in java?

0 Answers  


What are E and PI?

1 Answers  


What is the difference between interpreter and compiling ?

7 Answers   TCS,


What is JAVA? Why it is platform independent?

10 Answers   NIIT,


Categories