Results 1 to 6 of 6
  1. #1
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Posts
    114
    Rep Power
    0

    Default What does the following declaration means in the below code:ref List<int> C

    What does the following declaration means in the below code:

    Java Code:
     ref List<int> C



    Java Code:
    public static void Remove(List<int> A, List<int> B, ref List<int> C)
    {
        for (int k = C.Count-1; k >= 0; k--) // Reverse loop for removing elements in array correctly.
        {
            int i = 0, j = B.Count - 1;
            
            while (i < A.Count && j >= 0)
            {
                if (A[i] + B[j] == C[k])
                {
                    C.RemoveAt(k);
                    break;
                }
                else if (A[i] + B[j] < C[k])
                {
                    i++;
                }
                else
                {
                    j--;
                }
            }
        }
    }

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default Re: What does the following declaration means in the below code:ref List<int> C

    There's no ref keyword in Java as far as I know. Are you talking C# here?

  3. #3
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Posts
    114
    Rep Power
    0

    Default Re: What does the following declaration means in the below code:ref List<int> C

    Not really. It's Java. I'm referring to one of the solution from the following web page:

    ArrayList A, B, C are sorted i... | CareerCup


    Quote Originally Posted by wsaryada View Post
    There's no ref keyword in Java as far as I know. Are you talking C# here?

  4. #4
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default Re: What does the following declaration means in the below code:ref List<int> C

    How do you know it's Java? Can you compile it using Java? The link that you gave didn't say the program is written in Java. I am sure that the code is written in C#.

    1. You can't have a List<int> in Java.
    2. There is no ref keyword in Java.
    3. There's no Count property or RemoveAt() method in the List.
    4. Even the style and naming convention is not Java.
    Last edited by wsaryada; 04-10-2013 at 09:42 AM. Reason: Edit based on Tolls comment #5

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: What does the following declaration means in the below code:ref List<int> C

    Quote Originally Posted by wsaryada View Post
    1. You can have a List<int> in Java.
    Unless there's a change in Java 8 then no, you can't.
    The generic needs to be a class, not a primitive.

    (Or is that a typo?)
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default Re: What does the following declaration means in the below code:ref List<int> C

    Oops, that was a typo. It should be "You can't have a List<int> in Java". Thanks for correcting it.

Similar Threads

  1. need help Write code link list
    By falcon2000 in forum New To Java
    Replies: 12
    Last Post: 01-18-2013, 09:30 PM
  2. Linked List source code question
    By Empr1ze in forum New To Java
    Replies: 2
    Last Post: 08-15-2012, 07:05 PM
  3. what code for searching in drop down list?
    By Harmesh Goyal in forum Advanced Java
    Replies: 1
    Last Post: 03-03-2011, 04:43 AM

Posting Permissions

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