• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I pass vector in java?  RSS feed

 
arun singhal
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to pass a vector in java..
And I write A code given below..But have An error..This code is not working..
So please what should I need to do to remove error in this program.


Please give me solution of this...
 
Deepika Joshi
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Arun,

the problem is just that you're trying to access an instance (non-static) method from within a static context (the main method). Your code should work a expected by simply making the "vect" method "public static void".

Marco
 
arun singhal
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for helping..
It is working..
 
Marco Ehrentreich
best scout
Bartender
Posts: 1294
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome!

As an advice: You can usually solve such problems without help by simply using an IDE like NetBeans or Eclipse. That way an integrated Java compiler tells you what's wrong with your code just by typing this code into an editor window. It would have told you something similar to that I posted above

Marco
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as a general tip, saying "But have An error..This code is not working." is not helpful. If you get an error when compiling, tell us the error. Those 2-3 lines mean a LOT, and help focus in on the problem.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!