Results 1 to 2 of 2
  1. #1
    kris09 is offline Member
    Join Date
    Aug 2008
    Posts
    6
    Rep Power
    0

    Question what does num.length method does?

    i was wondering what does num.length method does ?



    import java.util.*;

    public class array2{
    public static void main(String[] args){
    int num[] = {50,20,45,82,25,63};
    int l = num.length; <--------
    int i,j,t;
    System.out.print("Given number : ");
    for (i = 0;i < l;i++ ){
    System.out.print(" " + num[i]);
    }
    System.out.println("\n");
    System.out.print("Accending order number : ");
    Arrays.sort(num);
    for(i = 0;i < l;i++){
    System.out.print(" " + num[i]);
    }
    }
    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,883
    Rep Power
    25

    Default

    length is like a field for an array. It gives the number of elements in the array.
    A method is coded with ending () -> size()

Similar Threads

  1. queue length of Socket
    By hemant in forum Networking
    Replies: 6
    Last Post: 07-13-2008, 07:28 PM
  2. Integer length
    By jithan in forum New To Java
    Replies: 1
    Last Post: 06-12-2008, 04:35 PM
  3. Demonstration of the variable length arguments
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 08:38 PM
  4. Determining Midi Length
    By Usagi in forum New To Java
    Replies: 0
    Last Post: 12-09-2007, 12:45 AM
  5. Help with method length
    By toby in forum New To Java
    Replies: 1
    Last Post: 07-25-2007, 09:29 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
  •