Java logical OR as per user input
<p>Requirement:
The program looks if a string is equal to the one or any of the characters entered by the user. The user may enter any numbers of entries separated by commas.</p>

<h2>In essence the code should be</h2>

<pre><code>if user inputs one value (X) // in[0] = X;

if(str.equals(in[0]))
{
// do something
}
</code></pre>

<hr>

<pre><code>if user inputs two values (X,Y) // in[0] = X; in[1] = Y;

if(str.equals(in[0]) || str.equals(in[1]))
{
// do something
}
</code></pre>

<hr>

<pre><code>if user inputs three values (X,Y,Z) // in[0] = X; in[1] = Y; in[2] = Z;

if(str.equals(in[0]) || str.equals(in[1]) || str.equals(in[2]))
{
// do something
}
</code></pre>

<p>And so on......
As you can see I cannot write such a dynamic if statement.
I would have liked to have something like the below work. Any suggestions?</p>

<p>Trial code:</p>

<pre><code>import java.io.BufferedReader;
import java.io.InputStreamReader;

 public class test {

 public static void main (String[] args) throws Exception {

 System.out.println("Enter the characters separated by commas");
 BufferedReader consoleinput = new BufferedReader(new InputStreamReader(System.in));
 String input = consoleinput.readLine();
 input = input.toUpperCase();
 String[] in = input.split(",");

 String str = "N";
 if (str.equals(in))
 {
 System.out.println("Match found"); 
 }
 else
 {
 System.out.println("No match"); 
 }

}
}
</code></pre>
