This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Eclipse Collections Categorically: Level up your programming game and have Donald Raab on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

problen with getting method to return array

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written a method (getArray) that does some stuff.
(I can't send the code as it is Cattle Drive Stuff)
it generates an array.
I can get it to sent the array to the screen using
System.out.println( intData( i ) );
But I do nto seem to be able to get the
array outside the method.
I am sure that I am doing something wrong in trying to
get my genArray() to return my array
that is a matter of not understaning the syntax
well enough.
HELP I feel like I am on the verge of making
a breakthrough if only I could tie my shoes.
;->
=========
public class CattleDrive
{
public static void main( String[] args )
{
String myString = //I get a string from somewhere
myArray[] = genArray( myString );//get the intarray of a string.
}
static int genArray( String s )
{
Magic Java stuff
System.out.println( myArray[ i ] );// this works
}
return myArray[];
}

------------------
=======================
Ione Walker
[email protected]
========================

------------------
=======================
Ione Walker
[email protected]
========================
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ione, in your genArray() you are only returning an int not an array of int's.
You have --> static int genArray( String s )
You should have --> static int[] genArray( String s )

Hope this helps.
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic