Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: deleting with shift ?

  1. #1
    Junior Member keep smiling's Avatar
    Join Date
    Oct 2011
    Location
    Italy
    Posts
    14
    My Mood
    Cool
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question deleting with shift ?

    i need only an example for deleting with shift in an array because i can't get it
    Java lover


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: deleting with shift ?

    Please see the link in my signature entitled 'Getting Help'...you need to provide a lot more information if you wish to receive replies that aren't simply guesses.

  3. #3
    Member
    Join Date
    Feb 2012
    Posts
    106
    My Mood
    Yeehaw
    Thanks
    8
    Thanked 11 Times in 11 Posts

    Default Re: deleting with shift ?

    i think (she?) means having a regular array, and wanting to use it as a list. so if she wants something in the middle deleted, she wants help moving the rest of the array over.

    If this isnt specifically being asked for by the teacher, use ArrayList, it does all that for you.

    otherwise say you want to delete the 4th index of an array named myArray

    posDeleted = 3

    for(int i=posDeleted; i< // the arrays length;i++)
    {
    myArray[i] = myArray[i+1];
    }

    something like that, but I have not used arrays for this job in a while so i forget the way to find out its length.
    also, i should never reach the last index of the array, it should only reach the second last(because it grabs from one index higher)
    also, you may want to make a new array that is smaller by 1 and be sticking everything in the new array to prevent lots of invalid data at the end not getting over ridden, or you can just write code to handle the last spot of the array and set it to a flag such as -1 or null

  4. The Following User Says Thank You to JonLane For This Useful Post:

    keep smiling (February 26th, 2012)

  5. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: deleting with shift ?

    Quote Originally Posted by JonLane View Post
    i think (she?) means having a regular array
    If someone wants their question to be answered concisely, then they should not assume we are mind readers and should provide all the information necessary. Feel free to guess, but given the information provided that is all it is at the moment - could be right, and could be wrong as shift could mean a great many things - moving array elements, deleting from an array using the shift key, and that doesn't even address what it means to delete (shorten an array, nullify elements, etc...). I say this because this poster has provided limited information in the past, and should learn that getting answers is intimately tied to how the question is asked.

  6. The Following User Says Thank You to copeg For This Useful Post:

    keep smiling (February 26th, 2012)

  7. #5
    Junior Member keep smiling's Avatar
    Join Date
    Oct 2011
    Location
    Italy
    Posts
    14
    My Mood
    Cool
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: deleting with shift ?

    ok i got the information i need
    and i won't make my question too general again to find the wanted answer
    Java lover

Similar Threads

  1. [SOLVED] Double key Caesar Cipher (USING A STACK AND A QUEUE TO SHIFT LETTERS OF A STRING)
    By Medo Almasry in forum What's Wrong With My Code?
    Replies: 16
    Last Post: November 19th, 2011, 04:18 PM
  2. Deleting Array Records
    By rainexel in forum Collections and Generics
    Replies: 3
    Last Post: September 26th, 2011, 11:40 AM
  3. How to shift a String in a rectangle which is type of Canvas
    By elenora in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: April 4th, 2011, 07:39 AM
  4. Deleting record from database HELP! :(
    By shando1992 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 2nd, 2011, 12:36 AM
  5. renaming/deleting file
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 15
    Last Post: January 15th, 2011, 12:18 AM