Results 1 to 4 of 4

Thread: Unknown Features of Java

  1. #1
    Join Date
    Jan 2009
    Posts
    30

    Unknown Features of Java

    Hi ,

    I know about most of features of JAVA language.
    But I am thinking regarding less used features of the JAVA language is a fun refresher.

    Do you think of any more "Unknown" features of this language? Or just anything interesting that not most of language user are familiar with?

    If you know some hidden properties or features of JAVA language ,Please share with us.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Unknown Features of Java

    Hello,

    I don't think anybody is familiar with this feature of JAVA language. See below code:

    public static void main(String[] args) {
    System.out.print("iexplore:");
    http://www.google.com;
    System.out.println(":maximize");
    }

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Unknown Features of Java

    I got surprised about return type generics feature of java.

    As I often use Java to write tests and need to select as well as generate testdata,

    the below code help to randomizing selection of data :


    public static <T> T selectRandom(List<T> list) {
    if (list != null) {
    int listSize = list.size();

    return listSize > 0 ? list.get(RANDOM_NUMBER_GENERATOR.nextInt(listSize)) : null;
    }

    return null;
    }

    public static <T> T selectRandom(T... array) {
    if (array != null) {
    return array.length > 0 ? array[RANDOM_NUMBER_GENERATOR.nextInt(array.length)] : null;
    }

    return null;
    }




    I hope this will also help you also

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Unknown Features of Java

    I am aware about a way to avoid some of the tedious as well as difficult casts with generics return from other generic methods

    public <x> x foo() {
    //blah
    return a;
    }

    public <y> y bar() {
    return <y>foo();
    }

Similar Threads

  1. Replies: 4
    Last Post: 04-09-2013, 11:04 PM
  2. Error "java.util.Arrays.mergeSort (Unknown Source)"
    By Fragant in forum Software Development
    Replies: 7
    Last Post: 09-09-2010, 10:18 PM
  3. Java/Selace.K trojan causing unknown downloads to occur
    By Jaimenacho in forum Networking & Security
    Replies: 5
    Last Post: 12-01-2010, 04:25 PM
  4. Link List Example in Java Sample program in Java
    By trickson in forum Software Development
    Replies: 2
    Last Post: 04-08-2009, 08:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,079,067.98192 seconds with 17 queries