Results 1 to 10 of 10
Like Tree1Likes
  • 1 Post By Norm

Thread: What does converting a string to long means?

  1. #1
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Posts
    113
    Rep Power
    0

    Default What does converting a string to long means?

    Could anyone explain with the example?

  2. #2
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: What does converting a string to long means?

    It means you parse a character sequence to a computer usable format of a number.

    Java Code:
    String sMyString = "412312315134";
    long   iMyLong = Long.parseLong( sMyString );
    I like likes!

  3. #3
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Posts
    113
    Rep Power
    0

    Default Re: What does converting a string to long means?

    I know adding two numbers represented as string is not possible but why are we declaring numbers as a String if we know that we have to add them in future? I hope you understand my question.

    Also closing someones thread without understanding his/her question properly is not appropriate.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: What does converting a string to long means?

    why are we declaring numbers as a String if we know that we have to add them in future?
    You're right. That makes no sense. Who wrote the code that is doing that? Did they add any comments explaining why they did it that way?
    Sierra likes this.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Posts
    113
    Rep Power
    0

    Default Re: What does converting a string to long means?

    No, that's my question. That's what I asked why would there be a need of converting String to long at all?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: What does converting a string to long means?

    If it were read from a text file, it would be a String.
    Or if it were typed into a textfield.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: What does converting a string to long means?

    Sadly those stupid users today have difficulties in communicating binary via RS232... actually keyboards would be a lot simpler if people could do that. So maybe you should google about ASCII and the evolution of the human interface.
    I like likes!

  8. #8
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,375
    Blog Entries
    7
    Rep Power
    20

    Default Re: What does converting a string to long means?

    Quote Originally Posted by Jack_Tauson_Sr View Post
    Also closing someones thread without understanding his/her question properly is not appropriate.
    If you mean your other identical thread: believe me, Darryl understood very well what this question is all about and double posts are closed (I usually merge them with the other thread or, when no replies are given yet, I simply remove them). Don't double post anymore.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  9. #9
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Posts
    113
    Rep Power
    0

    Default Re: What does converting a string to long means?

    Quote Originally Posted by Norm View Post
    If it were read from a text file, it would be a String.
    Or if it were typed into a textfield.
    Thanks Norm. That's the answer I was looking for.

  10. #10
    Jack_Tauson_Sr is offline Senior Member
    Join Date
    Nov 2011
    Posts
    113
    Rep Power
    0

    Default Re: What does converting a string to long means?

    Quote Originally Posted by Sierra View Post
    Sadly those stupid users today have difficulties in communicating binary via RS232... actually keyboards would be a lot simpler if people could do that. So maybe you should google about ASCII and the evolution of the human interface.
    Is your answer relevant to my question? I don't know what you are talking about.

Similar Threads

  1. String to Long
    By PhQ in forum New To Java
    Replies: 4
    Last Post: 01-04-2013, 04:18 PM
  2. Converting unsigned long to java
    By radhika.putty in forum Advanced Java
    Replies: 2
    Last Post: 04-01-2011, 05:31 AM
  3. Converting from long to int
    By peterhabe in forum New To Java
    Replies: 2
    Last Post: 02-20-2011, 06:14 PM
  4. stumpt. converting an object to a long int.
    By root_demon in forum New To Java
    Replies: 7
    Last Post: 10-31-2008, 05:32 AM
  5. Error: convert from String to long
    By bbq in forum New To Java
    Replies: 1
    Last Post: 06-29-2007, 07:23 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
  •