We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,621 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Accessioning A List Array From Another Class

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;
		  }}
3
Contributors
5
Replies
9 Hours
Discussion Span
1 Year Ago
Last Updated
6
Views
RLS0812
Newbie Poster
14 posts since Dec 2011
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 0

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

JamesCherrill
... trying to help
Moderator
8,497 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29

Supplying it with an argument creates more errors.

RLS0812
Newbie Poster
14 posts since Dec 2011
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 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.

JamesCherrill
... trying to help
Moderator
8,497 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29

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


J

JamesCherrill
... trying to help
Moderator
8,497 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29

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...

FALL3N
Junior Poster in Training
87 posts since May 2010
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0923 seconds using 2.71MB