Results 1 to 6 of 6
  1. #1
    Stamoulohta is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default apply an array to variables

    Hello to all,

    I am wondering if there is some way in java to apply an array to variables(in one line of code).
    In python the following works:
    Java Code:
    a = [1,2]
    b,c = a
    Is there any equivalent to this in java?

    Cheers.

    PS: Sorry for using python code but I find it easier to learn by comparison.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

    Default

    am wondering if there is some way in java to apply an array to variables(in one line of code).
    Nope.

    db

  3. #3
    chandra4reddy is offline Member
    Join Date
    Mar 2011
    Location
    Hyderabad
    Posts
    1
    Rep Power
    0

    Default

    c=a- -b;
    explain this pleaseeeeeeeeeeeeeee
    i can't understand this

  4. #4
    Stamoulohta is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default

    I am very sorry, this is not java code. I should't put it in this forum... apologies.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,005
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Stamoulohta View Post
    Hello to all,

    I am wondering if there is some way in java to apply an array to variables(in one line of code).
    In python the following works:
    Java Code:
    a = [1,2]
    b,c = a
    Is there any equivalent to this in java?

    Cheers.

    PS: Sorry for using python code but I find it easier to learn by comparison.
    In Java you can even do it in one line (excluding the type declarations of a, b and c)

    Java Code:
    a= new int[] { b= 1, c= 2 };
    But why write such obfuscated code or do you pay per line of code?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    Stamoulohta is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default

    hahaha ;D

    I was just trying to see in what ways can I manipulate arrays... My money aren't enough even if I payed per program suite.. ;)

    Cheers.

Similar Threads

  1. Apply a perspective transform
    By JdeSyph in forum New To Java
    Replies: 3
    Last Post: 03-07-2011, 08:39 AM
  2. How to apply PMD for JSP,HTML
    By Devarajan in forum Advanced Java
    Replies: 8
    Last Post: 01-28-2011, 09:48 AM
  3. Replies: 6
    Last Post: 11-03-2010, 02:33 PM
  4. Counting Duplicate Variables in an Array
    By Npcomplete in forum New To Java
    Replies: 2
    Last Post: 10-24-2008, 07:33 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
  •