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 7 of 7

Thread: what is the result and how?

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation what is the result and how?

    import java.util.*;
    4. public class Mapit {
    5. public static void main(String[] args) {
    6. Set<Integer> set = new HashSet<Integer>();
    7. Integer i1 = 45;
    8. Integer i2 = 46;
    9. set.add(i1);
    10. set.add(i1);
    11. set.add(i2); System.out.print(set.size() + " ");
    12. set.remove(i1); System.out.print(set.size() + " ");
    13. i2 = 47;
    14. set.remove(i2); System.out.print(set.size() + " ");
    15. }
    16. }
    What is the result?


  2. #2
    Member
    Join Date
    May 2011
    Location
    west palm beach, FL
    Posts
    189
    My Mood
    Tired
    Thanks
    41
    Thanked 11 Times in 10 Posts

    Default Re: what is the result and how?

    compile it and run it for the result....and all that code right there is the how lol what do you think the result is and how?

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: what is the result and how?

    o
    Last edited by pbj; July 13th, 2013 at 09:00 PM. Reason: removed code

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: what is the result and how?


  5. #5
    Junior Member
    Join Date
    Jul 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: what is the result and how?

    o

  6. #6
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: what is the result and how?

    Please do not feel as if you are under attack.
    But realize you provided an answer to a homework assignment from someone who was too lazy to even ask their own question, but just copy paste the assignment to the forum. This is called a homework-dump and we discourage academic dishonesty.

  7. #7
    Junior Member
    Join Date
    Jul 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: what is the result and how?

    o

Similar Threads

  1. Isn't the result supposed to be 6?
    By obel1x in forum Java Theory & Questions
    Replies: 3
    Last Post: April 12th, 2014, 03:43 AM
  2. I am not getting the result I need
    By Ormolu611 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: April 20th, 2013, 04:44 PM
  3. hi if u can help me please to figure this how D become result of 1
    By ohad in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 4th, 2013, 07:35 AM
  4. [SOLVED] Got different result from (Eclipse VS NetBean)
    By SmokyBrain in forum Java IDEs
    Replies: 4
    Last Post: May 4th, 2012, 07:08 AM
  5. Result set is closed
    By keshav_agrawal89 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: June 11th, 2011, 08:35 AM