• 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

Can you delete the elements of a static Vector from another class

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys is it possible to delete the elements of a static Vector from another class? For E.g.
Suppose we have a

And you want to delete the elements of this static Vector from another class:

Would this work?
Thanks

David
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Why don't you just try it out and see what happens?
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch
I would have added code tags to your post, which would have made it look better, but you had not idented the code.

The answer to your question is yes, and no.
Just because that code will compile and run (try it, when you have got rid of the spelling error in class) doesn’t mean it isn’t really poor design. I hope that is simply, “I wanted to see what happens if…” code.
 
David Fisher
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys. It did work but I know its a bad design. I just wanted to quickly find out if it worked. It was required in one of the method stub for a project that I'm doing. Basically its an Android project which has a number of classes and objects interacting with each other, etc. I'm new to the JavaRanch forums so pardon me


David
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Still bad design. You are using that List as a global variable, which is dubious. You can make it available via get methods. Or you can provide addToList(T t) and removeFromList(T t) methods, and make the List private.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic