Results 1 to 9 of 9
Like Tree4Likes
  • 1 Post By SurfMan
  • 1 Post By jim829
  • 2 Post By SurfMan

Thread: Convert int[] to int

  1. #1
    vknehra10 is offline Member
    Join Date
    Dec 2016
    Posts
    99
    Rep Power
    0

    Default Convert int[] to int

    how we convert int array to normal int...

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,939
    Rep Power
    7

    Default Re: Convert int[] to int

    And there is a one-liner question again. Stop dropping the oneliners in here, and ask a decent question. Give us an example, this is what I am trying, this is what I got instead, this is the error message, etc.

    Let me start by asking what is a "normal int"?
    jepoys1 likes this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    vknehra10 is offline Member
    Join Date
    Dec 2016
    Posts
    99
    Rep Power
    0

    Default Re: Convert int[] to int

    sorry..

    i want that

    int arr[]={1,2,3,4,5,6,7,8,9,10}

    i want to conveert this into int

  4. #4
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,939
    Rep Power
    7

    Default Re: Convert int[] to int

    You can't convert 10 ints to one int, unless you perform some operation on them like add, substract, etc.

    Using your own example, what would be the expected result?
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  5. #5
    benji2505 is offline Senior Member
    Join Date
    Sep 2014
    Location
    MA, USA
    Posts
    381
    Rep Power
    4

    Default Re: Convert int[] to int

    I would argue that there are already 10 int.

  6. #6
    NirelG is offline Member
    Join Date
    Mar 2017
    Posts
    10
    Rep Power
    0

    Default Re: Convert int[] to int

    Hi,

    To be honest, I am a bit new to java, but let me give you a simple tip from what I have learned up until now.
    Any 1 liner question already been asked before online...
    I wrote your title "Convert int[] to int" and found the same question from almost 6 years ago on another forum.

    Any way, regarding your question, it really depends what you want your output to be.

    Lets say we have int[] a = {1,1,2,3} do you want the output to be 1 int of 1123?
    Or maybe you meant it should be 1 random int out of the 4 ints inside the array?

    Without an explanation of what you want the output to be get it is impossible to help you...

  7. #7
    jepoys1 is offline Member
    Join Date
    Apr 2017
    Posts
    5
    Rep Power
    0

    Default Re: Convert int[] to int

    Quote Originally Posted by NirelG View Post
    Lets say we have int[] a = {1,1,2,3} do you want the output to be 1 int of 1123?
    Are you implying that his int[] a has a value of 1123?

  8. #8
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,145
    Rep Power
    12

    Default Re: Convert int[] to int

    No. I am certain he is trying to figure out what the OP wanted. So summing up the array values where each element occupies an appropriate
    power of ten would "convert" the int array to an single int. But it's a stretch. Bottom line, it does not make sense to talk about converting
    an array of type T to a single value of type T unless you do some kind of reduction on the array.

    Regards,
    Jim
    jepoys1 likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  9. #9
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,939
    Rep Power
    7

    Default Re: Convert int[] to int

    It's not uncommon for this poster to dump a question and never come back. I wouldn't worry too much about it.
    jepoys1 and NirelG like this.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

Similar Threads

  1. Convert SQL to HQL
    By kattoha in forum Hibernate
    Replies: 0
    Last Post: 02-26-2016, 06:16 PM
  2. Convert jar to dll
    By pennaverde in forum New To Java
    Replies: 6
    Last Post: 01-13-2012, 03:47 AM
  3. cannot convert from int to int[][]
    By besweeet in forum New To Java
    Replies: 9
    Last Post: 04-18-2010, 04:36 AM
  4. how to convert xml to xsd
    By adi in forum XML
    Replies: 2
    Last Post: 02-12-2009, 03:43 PM
  5. need the help to convert to and from UTF-8 and UCS-2
    By sachin_n in forum Advanced Java
    Replies: 1
    Last Post: 01-05-2009, 10:35 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
  •