Results 1 to 15 of 15
  1. #1
    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0

    Default How Object array will be converted to integer array in the following example

    public static void main(String[] args) {
    Object obj = new int[] { 1, 2, 3 };
    int[] someArray = (int[])obj;
    for (int i : someArray) System.out.print(i + " ");
    }

    Result here is 1 2 3

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,017
    Rep Power
    10

    Default Re: How Object array will be converted to integer array in the following example

    Do you have a question?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Join Date
    Aug 2013
    Posts
    3
    Rep Power
    0

    Default Re: How Object array will be converted to integer array in the following example

    I cant get you Kevin

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,280
    Rep Power
    6

    Default Re: How Object array will be converted to integer array in the following example

    Why did you make this thread?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

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

    Default Re: How Object array will be converted to integer array in the following example

    Suppose you're pointing at an animal but you don't know what it is; you go "hey, an animal!". I pass by and tell you it's an aardvark. All of a sudden you're pointing at an aardvark. Did the animal convert to an aardvark? No, it was an aardvark already. Read 'object' for 'animal' and 'int[]' for 'aardvark' and you get the picture ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,280
    Rep Power
    6

    Default Re: How Object array will be converted to integer array in the following example

    Ah, I see Jos has dusted off his crystal ball. I demand you tell me the jackpot lottery number (staatsloterij) for next month!
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

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

    Default Re: How Object array will be converted to integer array in the following example

    Quote Originally Posted by gimbal2 View Post
    Ah, I see Jos has dusted off his crystal ball. I demand you tell me the jackpot lottery number (staatsloterij) for next month!
    I don't know, I only know things about aardvarks ...

    kindest regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: How Object array will be converted to integer array in the following example

    Ethel the aardvark goes quantity surveying!

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default Re: How Object array will be converted to integer array in the following example

    Quote Originally Posted by JosAH View Post
    I don't know, I only know things about aardvarks ...
    Commendable modesty, but we all know you're the world's leading expert on elderberries and hamsters.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  10. #10
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,280
    Rep Power
    6

    Default Re: How Object array will be converted to integer array in the following example

    Quote Originally Posted by JosAH View Post
    I don't know, I only know things about aardvarks ...
    Lies, you just want to keep it all for yourself. I won't forget this sir, the next time you have an opinion I am going to go ahead and disagree with it by default. Puh!
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

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

    Default Re: How Object array will be converted to integer array in the following example

    Quote Originally Posted by gimbal2 View Post
    Lies, you just want to keep it all for yourself. I won't forget this sir, the next time you have an opinion I am going to go ahead and disagree with it by default. Puh!
    Me, being the founding father of the SFROPAAFGB(WTCT) (Society For Rehabilitation Of Poor Aardvarks And Free Grolsch Beer (With The Ceramic Top) wiggle my genitals in your general direction, so there! :-P

    kindest regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  12. #12
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,280
    Rep Power
    6

    Default Re: How Object array will be converted to integer array in the following example

    Curses! I am foiled!
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

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

    Default Re: How Object array will be converted to integer array in the following example

    Quote Originally Posted by gimbal2 View Post
    Curses! I am foiled!
    <diabolical laughter>Hahahahaaaa!<diabolical laughter/> now confess you old woman that you didn't expect the SFROPAAFGB(WTCT; as a matter of fact, noone expects the SFROPAAFGB(WTCT!

    kind regards,

    Jos (<--- poking around with soft cushions)
    cenosillicaphobia: the fear for an empty beer glass

  14. #14
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,280
    Rep Power
    6

    Default Re: How Object array will be converted to integer array in the following example

    That just got into a whole different level of weird. I think you've been sampling the Amstel and there are now toxic bubbles in your brain.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

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

    Default Re: How Object array will be converted to integer array in the following example

    Quote Originally Posted by gimbal2 View Post
    That just got into a whole different level of weird. I think you've been sampling the Amstel and there are now toxic bubbles in your brain.
    Don't be silly; the moment they find me sampling Amstel I deserve to be shot in the head in a merciful way. (for the foreigners among us: the Amstel is a polluted little river; you can't brew beer out of it).

    kindest regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Integer array to String array
    By lakshmibvaraprasad in forum New To Java
    Replies: 1
    Last Post: 07-20-2011, 09:39 PM
  2. Replies: 23
    Last Post: 09-07-2010, 09:12 PM
  3. An Array of different integer values
    By lithium002 in forum New To Java
    Replies: 7
    Last Post: 12-04-2009, 06:25 AM
  4. Replies: 1
    Last Post: 03-31-2009, 07:40 AM
  5. Replies: 4
    Last Post: 03-25-2008, 01:16 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
  •