Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 24th, 2012, 10:28 PM
theaveguy theaveguy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 7 theaveguy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #2  
Old February 25th, 2012, 01:10 AM
theaveguy theaveguy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 7 theaveguy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 23 sec
Reputation Power: 0
Any help? I would really like to get my program going, I was searching the String API Docs and only saw things pertaining to char/string nothing about array/sting.

Reply With Quote
  #3  
Old February 25th, 2012, 10:41 AM
NormR's Avatar
NormR NormR is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2010
Location: SW Missouri
Posts: 3,040 NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level)NormR User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 15 h 36 m 54 sec
Reputation Power: 346
See the answer posted on the other forum where you posted this question.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Contain method to read array

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap