• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Vectors within vectors

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please UseCodeTags.
 
Yun Lee
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Please UseCodeTags.



Edited. Please help!!
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 152
VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

     
    reply
      Bookmark Topic Watch Topic
    • New Topic