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

Thread: initialise set that holds value of array

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default initialise set that holds value of array

    Hello,

    Can you please tell me how to initialise a sorted set that holds the values of an array of class static variable.

    I have an array - public static int[ ] InDays {4, 5, 9, 12, 15, 16, 20, 23, 28, 30};

    and I need to assign it to SortedSet<Integer> InDaysAtWork

    Many thanks


  2. #2
    Junior Member switcha's Avatar
    Join Date
    Sep 2011
    Location
    Australia
    Posts
    20
    My Mood
    Fine
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: initialise set that holds value of array

    public static final int InDays [] = { 4, 5, 9, 12, 15, 16, 20, 23, 28, 30 };
     
    //create SortedSet
    SortedSet< "Insert Type Here" > InDaysAtWork = new SortedSet< "Insert Type Here" >( Arrays.asList( InDays ) );
    ...you'll have to figure out the type to insert and remove the quotation marks.
    That's all I'm giving you
    Last edited by switcha; September 15th, 2011 at 06:18 PM.

Similar Threads

  1. how to initialise set in a constructor
    By davie in forum Collections and Generics
    Replies: 3
    Last Post: March 12th, 2010, 05:35 PM
  2. [SOLVED] Create new Array from old Array
    By satory in forum Collections and Generics
    Replies: 1
    Last Post: February 24th, 2010, 12:44 PM
  3. Object array to int array?
    By rsala004 in forum Collections and Generics
    Replies: 1
    Last Post: October 30th, 2009, 04:09 AM
  4. Storing an array into an array
    By vluong in forum Collections and Generics
    Replies: 4
    Last Post: September 22nd, 2009, 02:14 PM