
February 24th, 2012, 10:28 PM
|
|
Registered User
|
|
Join Date: Feb 2012
Posts: 7
Time spent in forums: 2 h 36 m 23 sec
Reputation Power: 0
|
|
|
Contain method to read array
I am trying to find a method to read an array like this.
Code:
String[] operators = {"+", "-"};
if(operation.contains(operators))
System.out.println("noob");
else
System.out.println("noobcake");
The contains method will not read from the array but it works when I use it like this,
Code:
if(operation.contains("/") || (operation.contains("divide") || (operation.contains("division") || (operation.contains("Divide") || (operation.contains("Division"))))))
System.out.println(total = firstnumber / secondnumber);
else
System.out.println("You didn't enter a Valid Operator");
but this uses a bunch of unnecessary space and would be easier to edit with an array.
So my question is what method can I use to read from the array and apply to this situation?
I started java a week ago, so I am just trying to get used to it, and write lots of test programs.
|