Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Methods

 
afolabi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could somebody please show me the code for writing a method that accept 1 argument - array of strings, and also converts the values in the array of strings into integers.
Thank you.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
afolabi,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner! Hope to see you 'round the Ranch!
 
Tom Blough
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For an example of a method that takes an array of strings, look no futher than

To convert the strings to integers, you will need to iterate through the array with a for loop. Inside the loop, you can use some of the methods in the Integer class to convert the string into and integer value.
Give this a try. If you still run into problems, post your code and we'll give you some additional pointers. This looks like a homework problem. Most of the ranch hands here will be happy to give advice, but we won't provide a complete solution for you.
Good luck!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic