1,105,286 Community Members

Accessioning A List Array From Another Class

Member Avatar
RLS0812
Newbie Poster
22 posts since Dec 2011
Reputation Points: -3 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

It's going on 4 hours now, and I have yet to find an answer on how to do this.

All I want to do access and manipulate data in a list, from another class.

The 2 classes:
GetList.java

public class GetList {
  public static void main(String args[])  
  {
	  MakeList xx = new MakeList();
	  System.out.println(xx.NameHere() + " " ); // < < < < Error
	  }
	  }

And
MakeList.java

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;


public class MakeList {
	public List<String> NameHere (String args[])  
	{
		  List<String> listname = new ArrayList<String>();
		  listname.addAll(Arrays.asList("e","f","g") );
		  return listname;
		  }}
Member Avatar
JamesCherrill
... trying to help
10,362 posts since Apr 2008
Reputation Points: 2,081 [?]
Q&As Helped to Solve: 1,749 [?]
Skill Endorsements: 47 [?]
Moderator
Featured
 
0
 

NameHere is a method that takes a String[] as a parameter. You try to call it without supplying a parameter

Member Avatar
RLS0812
Newbie Poster
22 posts since Dec 2011
Reputation Points: -3 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Supplying it with an argument creates more errors.

Member Avatar
JamesCherrill
... trying to help
10,362 posts since Apr 2008
Reputation Points: 2,081 [?]
Q&As Helped to Solve: 1,749 [?]
Skill Endorsements: 47 [?]
Moderator
Featured
 
0
 

And using my telepathic powers to see what argument you used and exactly what the errors were, I can tell that .... oh dear, telepathic powers failed.

Member Avatar
JamesCherrill
... trying to help
10,362 posts since Apr 2008
Reputation Points: 2,081 [?]
Q&As Helped to Solve: 1,749 [?]
Skill Endorsements: 47 [?]
Moderator
Featured
 
0
 

OK, OK, don't take it personally! If you post the exact code and the exact error message(s) I'll help.


J

Member Avatar
FALL3N
Junior Poster in Training
88 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

lol, I think he may have taken it seriously... ;)

but as for the problem, just remove the 'String[] args' parameter from the 'public List<String> NameHere (String args[]) ' method declaration... I'm not sure how that parameter is helpful...

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: