Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training Big Data and Hadoop Training Java Training  
 

a interview questioon

Ads

 
 

Share on Google+Share on Google+

saswat dash
a interview questioon
1 Answer(s)      6 years and 8 months ago
Posted in : Java Interview Questions

write a programme so the it can print each substring of a string like "saswat" is the string then it will print s,a,w,t,sa,swa,sta,as,aws,ats,sasw all posible sub string with out repeating

Ads
View Answers

December 13, 2010 at 3:46 PM


Hi Friend,

Try the following code:

import java.util.*;

class SubstringExample{
static Set set = new HashSet();
    public static void generate(String str){
        set.add(str);

        if (str.length() == 1){
            set.add(str);
            return;
        }
        for (int i = 0; i < str.length(); i++){
            generate(str.substring(0,i) + str.substring(i+1));
        }
    }
    public static void main(String args[])
    {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter a String: ");
        String st = scanner.nextLine();
        generate(st);
        System.out.println(set);
    }
}

Thanks


Ads









Related Tutorials/Questions & Answers:
a interview questioon
a interview questioon  write a programme so the it can print each substring of a string like "saswat" is the string then it will print s,a,w,t,sa,swa,sta,as,aws,ats,sasw all posible sub string with out repeating   Hi
interview - Java Interview Questions
interview  kindly guide me some interview questions of Java
Advertisements
Interview Que
Interview Que  I want to Java Interview Questions   Please visit the following link: Java Interview Questions
Interview Question - Java Interview Questions
Interview Question  I need Interview Questions on Java,J2EE Pls help me
interview questions - Java Interview Questions
interview questions for Java  Hi Any one can u please post the interview point of questions.Warm Regards, Satish
Interview question
Interview question  what is mean by Dynamic class loading
Interview question - Java Interview Questions
Interview question   Hi Friends, Give me details abt synchronization in interview point of view. I mean ow to explain short and neat. Thanks
Interview Tips - Java Interview Questions
Interview Tips  Hi, I am looking for a job in java/j2ee.plz give me interview tips. i mean topics which i should be strong and how to prepare. Looking for a job 3.5yrs experience
tech. interview
tech. interview   java support round robin algo. if yes why? and if no why
Interview question - JSP-Interview Questions
Interview question   Hi Friend, Can we inherit interface in JSP. Thank u in advance
java interview question and answer - Java Interview Questions
java interview question and answer   sir, i want one mark java interview question and answers
interview question - Java Interview Questions
interview question  hello i want technical interview question in current year   Hi Friend, Please visit the following links: http://www.roseindia.net/interviewquestions/ http://www.roseindia.net
interview question - Servlet Interview Questions
interview question  What is Servlet? Need interview questions on Java... and HTTP Servlet.While going through an interview you could be asked for number... according to your experience.And for collection of Java Servlet Interview Question you
Client Interview
Client Interview  Hi, I am kumar i am having client round in polaries client is a BANK. how to face client interview. what are the expected questions from CITI
java interview - JSP-Interview Questions
java interview  what type of questions would be asked to a 3 years experience person in java? can anyone please provide list of topics or interview questions for 3 years experience in java
java - Java Interview Questions
Helpful Java Interview questions   Need Helpful Java Interview questions
Jsp - Java Interview Questions
Need JSP Interview Questions  Hi, I need JSP interview questions.Thanks
struts interview Question - Struts
struts interview question and answer java  struts interview question and answer java
Java Interview Questions
Java Interview Questions  Hi, Can anyone tell the urls of Java Interview Questions on roseindia.net? Thanks
Struts - Java Interview Questions
Struts Interview Questions  I need Java Struts Interview Questions and examples
About interview questions
About interview questions   I want interview questions on IDE's Please send links
Interview question - Java Interview Questions
Interview question   Hi Friends, I am new to java, can u tell me what is class ,object and instance with example. For example : class raja , raja r = new raja(); ,here raja is class and r is instance
Hi - Hibernate Interview Questions
Hi   please send me hibernate interview questions
JAVA INTERVIEW QUES
JAVA INTERVIEW QUES  what is meant by CTS in JAVA
java interview question
java interview question  what is the usage of abstract class
java - Java Interview Questions
java  MNC now which modal question are asked in interview
struts interview question in ibm
struts interview question in ibm  what is the use of "format" attribute
java interview question
java interview question  when will we use abstraction or interface
interview path pdf
interview path pdf  Plz send me the paths of java core questions and answers pdfs or interview questions pdfs... the interview for any company... the following link: Interview Questions and their Answers
Hibernate interview Questions
Hibernate interview Questions  Pl share hibernate interview..., but in that they have currently not updated interview questions. They have explain so many new technology with pictorial example and sample programs but interview question
java - Servlet Interview Questions
java  servlet interview questions  Hi friend, For Servlet interview Questions visit to : http://www.roseindia.net/interviewquestions/servlet/ Thanks