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
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 |
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 |
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 |
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 |
Discuss 2D arrays.
What are the different http methods?
Can you make a constructor final?
How do you pass by reference?
Which non-unicode letter characters may be used as the first character of an identifier?
How many characters is 2 bytes?
we cannot create an object of interface but we can create a variable of it
what is meant by Byte code concept in Java?
What is the difference between the final method and abstract method?
What is clipping and repainting and what is the relation between them?
How to make a method thread safe without using synchronized keyword?
8 Answers Persistent, Societe Generale,
Write a java program to find the route that connects between Red and Green Cells. General Rules for traversal 1. You can traverse from one cell to another vertically, horizontally or diagonally. 2. You cannot traverse through Black cells. 3. There should be only one Red and Green cell and at least one of each should be present. Otherwise the array is invalid. 4. You cannot revisit a cell that you have already traversed. 5. The maze need not be in the same as given in the above example