Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vectors within vectors

 
Yun Lee
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've made a vectors within vectors, and now trying to initialise it, I just can't get it to work.

The problem is in lines 64 ~ 67, PLEASE help me out!!


thanks.



PLEASE HELP!!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags.
 
Yun Lee
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Please UseCodeTags.


Edited. Please help!!
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yun Lee wrote:Edited.

Do you really not indent your code? Do you think it's easy to read as it is?
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You said you had a problem with that code; would you like to explain what it is? Even for somebody who wants to try reading that code, there isn't much point without having some idea of what to look for.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't post the same question more than once. I am locking your previous post.
 
Yun Lee
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:You said you had a problem with that code; would you like to explain what it is? Even for somebody who wants to try reading that code, there isn't much point without having some idea of what to look for.


yeah the problem is in the last section;



Basically I am trying to bring/initialise the values from the vectors within the vectors... so in each slot of the teamVector is another vector, so I am trying to bring those out, but it won't work...

String teamVector.get(1) works and gets the values of the whole vector, but when I ask for a specific slot in the vector (inside the main vector), it won't work. Maybe I should write something other than StringteamVector.get(1).get(1) ?


And the mods: I've just joined today, and the only rule was 'be nice'. Someone already told me not to post twice and that was enough. Not every single 'sheriff' needs to come and repeat what other sheriffs say. Thank you.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I didn't read through both of your other identical posts. That aside, there's nothing "not nice" about telling you the rules, and enforcing them.
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say "won't work", can you be more specific?

I mean, to me it looks like that code fragment won't even compile. So I don't see how you could run it to see what it does. But anyway, it would be helpful for you to explain your problem. If you have error messages, then tell us what they are. Tell us whether they are compiler errors or runtime errors. Post stack traces if you get them. And so on.
 
Matt Cartwright
Ranch Hand
Posts: 152
Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this dog won't hunt

  • the clone() method defined on java.lang.Object returns an object of type Object. This cannot be assigned to an object of type Vector. Why do you need to clone?


  • When instantiating the Defender object, you are using "int" which in this context is a syntax error. Remove them.


  • Let's assume your defender definition is something like:


    To make all the warnings (type safety) go away, your method signatures need changing to:

    Its gotta match the your teamVector definition.


    So if you then change it to:


    the dog starts running

     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic