Results 1 to 5 of 5
  1. #1
    Christa912 is offline Member
    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0

    Default Simple pointer question?

    I have a class called password,which stores a list of strings. The program shortens the list as it runs , but I need a way to store the original list.
    I tried Password original= thePass; but that just points to the same location as thePass so it's useless. How do I store the original?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,026
    Rep Power
    6

    Default Re: Simple pointer question?

    It depends on how you store the passwords within the class. If it s an array, create a new array. if it is a List implementation, create a new list. When you exhaust one, copy the preserved to the exhausted.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,776
    Blog Entries
    7
    Rep Power
    21

    Default Re: Simple pointer question?

    Store a copy of the original list (there are constructors in the several List implementations that can do it).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Christa912 is offline Member
    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0

    Default Re: Simple pointer question?

    Alright, I didn't create the password class(and i can't see how its set up),so I'll just trial and error until it works.
    Thanks!

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,026
    Rep Power
    6

    Default Re: Simple pointer question?

    But there must be a way of initializing the class to begin with (otherwise it's pretty useless). So simply store an array or list of passwords and when the class has used them up, create a new instance of the password class and re-initialize it.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. null pointer exception question
    By zlloyd1 in forum New To Java
    Replies: 5
    Last Post: 01-26-2013, 03:15 PM
  2. Simple App Question
    By skylab in forum Android
    Replies: 2
    Last Post: 08-13-2012, 03:37 PM
  3. Replies: 3
    Last Post: 02-11-2012, 09:03 PM
  4. simple question
    By agater in forum New To Java
    Replies: 5
    Last Post: 11-07-2011, 03:22 AM
  5. Simple Question
    By stackptr89 in forum New To Java
    Replies: 13
    Last Post: 01-29-2011, 06:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •