• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot call method  RSS feed

 
Scott M Summers
Ranch Hand
Posts: 42
Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am trying to call a method, run(Object[] system_task_objects), in my main method. In the past I have been able to call methods that have primitive data types as parameters, but I cannot with an array. Line # 56 is where I am unable to call the run method.
Thank you.

Code:


 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By "I am unable to call the run method" do you mean that you are getting error while compiling or is it throwing exception while execution?
And what are you getting in the console?
 
Scott M Summers
Ranch Hand
Posts: 42
Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a compile error.
With line #56: run(Object[] system_task_objects);
I get the error;
unexpected type
required:value
found: class

'.class' expected

';' expected
----
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott M Summers wrote:I have a compile error.

OK, what do you think
  run(Object[] system_task_objects);
is going to do?

Have a look at the other places you call methods. Do they look like your run() call?

Winston
 
Scott M Summers
Ranch Hand
Posts: 42
Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, what do you think
  run(Object[] system_task_objects);
is going to do?

Have a look at the other places you call methods. Do they look like your run() call?

Winston


No, it doesn't look like other methods I've called.
Calling a method with no parameters would be, methodName();
Calling a method with int parameters would be, methodName(2,3);
I'm not sure what is required for arrays.
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott M Summers wrote:Calling a method with int parameters would be, methodName(2,3);

Yes you call method like this.
You do not call the method like
methodName(int 2, int 3);

do you?
Now you got some clue?
 
Scott M Summers
Ranch Hand
Posts: 42
Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried, run(system_task_objects);
same issue.
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From other point of view.

1. In order to be able to use method, you have to define it:

2. When you have defined method, you can call it:

3. When you call method and supply specific arguments, you need to make sure you have defined method with those parameters.

Note, it could look that i'm using words "parameters" and "arguments" interchangeably, but it is not fully right.
Parameters - are the ones which method can accept, arguments - the ones you can pass to the method. So when you see next time these in a book, you'll know
 
Scott M Summers
Ranch Hand
Posts: 42
Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Liutauras Vilda wrote:From other point of view.

1. In order to be able to use method, you have to define it:

2. When you have defined method, you can call it:

3. When you call method and supply specific parameters, you need to make sure you have defined method with those parameters.

Note, it could look that i'm using words "parameters" and "arguments" interchangeably, but it is not fully right.
Parameters - are the ones which method can accept, arguments - the ones you can pass to the method. So when you see next time these in a book, you'll know


Thank you that helped a lot. And good to know about parameters & arguments. Thanks again.
 
Liutauras Vilda
Sheriff
Posts: 4917
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott M Summers wrote:Thank you that helped a lot. And good to know about parameters & arguments. Thanks again.

You're welcome, and welcome to Ranch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!