Its not entering the If loop in the code snippet, couldn't get what's wrong in this logic.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
//first extract any userdefined letter from word and form a word
package myfirst;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
/**
*
* @author kiit
*/
public class Wrdpttrn {
InputStreamReader inp = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(inp);
StringBuilder sb=new StringBuilder();
Scanner scanner = new Scanner(System.in);
public void extractWord(String t){
char arr[]=t.toCharArray();
// boolean b;
for(char c : arr){
System.out.println("myfirst.Wrdpttrn.extractWord()"+c);
}
for(int i=0;i<=t.length();i++){
char c1 = scanner.next().charAt(0);
System.out.println("Enter character from particular string sequence:"+c1);
if(t.equalsIgnoreCase(String.valueOf(c1))){
//boolean b=true;
System.out.println("You have entered: "+c1);
System.out.println("Enter character from particular string sequence1:");
sb.append(c1);
}
// else{
//b=false;
// }
//if(b){
//System.out.println("Enter character from particular string sequence2:");
//sb.append(c1);
}
}
public static void main(String args[]){
Wrdpttrn wp=new Wrdpttrn();
wp.extractWord("shabana");
}
}
0 Answer(s)