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
who can i handle multiple client in RMI
Is there any way to find whether software installed in the
system is registered by just providing the .exe file?
I have tried the following code but its just displaying the
directory structure in the registry.
Here the code :
package com.msi.intaller;
import java.util.Iterator;
import ca.beq.util.win32.registry.RegistryKey;
import ca.beq.util.win32.registry.RootKey;
public class RegistryFinder {
public static void main(String... args) throws Exception
{
RegistryKey.initialize(RegistryFinder.class.getResource("jRe
gistryKey.dll").getFile());
RegistryKey key = new RegistryKey(RootKey.HKLM,
"Software\\ODBC");
for (Iterator
What is the functionality of the stub?
why Java does not support multiple inheritances?
What will happen if non-synchronized method calls a static synchronized method and what kind of lock it acquires?
What is an object class?
How do you find the independent variable?
What are the advantages of unicode?
What is string data type?
What is the indent key?
Is oracle java 11 free?
What is the static import?
What happens to a static var that is defined within a method of a class?
Why scanner is used in java?
I want to print “hello” even before main is executed. How will you acheive that?