Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

How can get an out that you have 2 input characters at the same time..

  Asked By: Klarissa    Date: Oct 06    Category: Java    Views: 528
  

this my problem..how can get an out that you have 2 input characters
at the same time..

input1: r
input2:g

if (input1=='r'&&input2=='g')
System.out.println(" rg");

but how come he doesnt read the System.out..

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Balbir Kaur     Answered On: Oct 06

> if (input1=='r'&&input2=='g')
> System.out.println(" rg");


if ( input1.equals('r') && input2.equals('g') )
{
System.out.println(" rg");
}

 
Answer #2    Answered By: Rene Sullivan     Answered On: Oct 06

wat I understand is that your input1 & input2 are strings & making an "=="
comparator won't work here as it compares refrences rather than the content.
better use input1.equals("r") && input2.equals("g"). guess shud work.

 




Tagged: