Results 1 to 19 of 19
Like Tree3Likes
  • 2 Post By jim829
  • 1 Post By zFollette

Thread: I want to know the flow

  1. #1
    jomajoms is offline Member
    Join Date
    Dec 2013
    Posts
    10
    Rep Power
    0

    Question I want to know the flow

    public class Test{

    public static void main(String args[]){
    int x =Integer.parseInt("9");
    double c = Double.parseDouble("5");
    int b = Integer.parseInt("444",16);

    System.out.println(x);
    System.out.println(c);
    System.out.println(b);
    }
    }





    I want to know why the answer of "int b" is 1092.

    can someone help me explain?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,656
    Rep Power
    5

    Default Re: I want to know the flow

    (4 * 256) + (4 * 16) + 4
    1024 + 64 + 4
    1088 + 4
    1092

    Regards,
    Jim
    SurfMan and jomajoms like this.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: I want to know the flow

    To add to Jim's excellent answer: the second parameter is the base of the number, in this case base 16, which is better known as hexadecimal.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2™ © 2013

  4. #4
    jomajoms is offline Member
    Join Date
    Dec 2013
    Posts
    10
    Rep Power
    0

    Default Re: I want to know the flow

    Thanks for your help Jim, I'm new in java and I would like to explore all logic and information involve in this field.

  5. #5
    jomajoms is offline Member
    Join Date
    Dec 2013
    Posts
    10
    Rep Power
    0

    Default Re: I want to know the flow

    Thanks surfMan

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

    Default Re: I want to know the flow

    Quote Originally Posted by jomajoms View Post
    Thanks for your help Jim, I'm new in java and I would like to explore all logic and information involve in this field.
    So what are you going to do about that so that you may actually do that yourself? I mean your intention was brilliant: you wanted to know WHY and that is a very important question to answer; congratulations on being one step ahead of your peers who only focus on the HOW and actually gain very understanding in doing that.

    But then it is a bit of a problem that you couldn't go answer it yourself. I wonder why? What are you missing that stopped you from investigating it? To me that is far more important information to get than only this one answer to this one question.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,656
    Rep Power
    5

    Default Re: I want to know the flow

    If you understand how the decimal system works then you can understand any other base. In the decimal system, you have from right to left, powers of 10 starting with exponent 0. And you have 10 symbols to work with, 0-9. In binary, you have powers of 2 and the symbols 0 and 1. So for any base b, you have powers of b and b symbols. By convention, the symbols first start with the digits and then employ the Latin alphabet. Check out base conversion on the web. Note: I checked out Wikipedia and IMO the article tends to over complicate a relatively simple concept.

    Regards,
    Jim
    Last edited by jim829; 12-31-2013 at 03:34 PM.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  8. #8
    jomajoms is offline Member
    Join Date
    Dec 2013
    Posts
    10
    Rep Power
    0

    Default Re: I want to know the flow

    Thanks anyway for your concern gimbal, I stopped investigating about that program because I was not able to explore the whole java codes and functions and basically I need more logical information in this field. I know some logical way but I think it is different in java. I would like to have a good mentor in basic java logic, like this command element = Integer.parseInt(String element); I dont have any Idea how that instruction function, I just saw it in the error report below that it called parsing, and I don't know about parsing. I just need to know that to finish my ATM machine program, since that kind of program includes lot of parsing, I know it because I just saw it in some example of my friends.

  9. #9
    jomajoms is offline Member
    Join Date
    Dec 2013
    Posts
    10
    Rep Power
    0

    Default Re: I want to know the flow

    jim do you have any logical presentation in your explanation, i mean some element that you could replace based on what you have expressed in your explanation?

  10. #10
    jomajoms is offline Member
    Join Date
    Dec 2013
    Posts
    10
    Rep Power
    0

    Default Re: I want to know the flow

    i'll just experiment and try to make some basic to complicated program to clear my mind, i mean to clarify my doubts about java.

    Thanks gimbal2,
    JomaJoms
    Last edited by jomajoms; 01-01-2014 at 04:11 AM. Reason: Missing word

  11. #11
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,656
    Rep Power
    5

    Default Re: I want to know the flow

    XML Code:
    Decimal
    10^3  10^2  10^1  10^0
      3     4     1     2    = decimal 3412 in decimal (3 x 1000) + (4 x 100) + (1 x 10) + (2 x 1) = 3412
    
    Binary
      2^3  2^2  2^1  2^0 
       1    1    0    1  =  decimal 13 in binary (1 x 8) + (1 x 4) + (0 x 2) + (1 x 1) = 13
    
    Hexadecimal
    16^3  16^2  16^1  16^0
      2     A     7     F =  decimal 10879 in hex (2 x 4096) + (10 x 256) + (7 x 16) + (15 x 1) = 10879
    Other bases work exactly the same way.

    Regards,
    Jim
    Last edited by jim829; 01-01-2014 at 04:57 AM.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  12. #12
    jomajoms is offline Member
    Join Date
    Dec 2013
    Posts
    10
    Rep Power
    0

    Default Re: I want to know the flow

    That satisfies my doubts, i've been looking for that kind of logic, I encountered that already in my logic class by I cant relate it in java, I don't have any idea that that kind of logic or topic is also include in java. Thanks anyway Jim.

    Thanks,
    JomaJoms
    Last edited by jomajoms; 01-01-2014 at 10:26 AM. Reason: incorrect name

  13. #13
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,656
    Rep Power
    5

    Default Re: I want to know the flow

    It has nothing to do with Java. It is just about presenting values in different bases. It is a fundamental concept in computer science. Expressing values in binary or hex is useful when you want to do bit manipulation. Sometimes it makes more sense to display a value in hex rather than decimal (but it depends on the application and what the programmer is trying to convey). Among many other topics it is worth knowing and understanding.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  14. #14
    jomajoms is offline Member
    Join Date
    Dec 2013
    Posts
    10
    Rep Power
    0

    Default Re: I want to know the flow

    Thanks, by the way I'm now doing my ATM machine program and I'm confused in using showConfirmDialog in JOptionPane. can you explain it? I'm done parsing it and it is stated that it requires: String , Found: Int.

  15. #15
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,656
    Rep Power
    5

    Default Re: I want to know the flow

    I have not used it before but I or others will certainly be able to help. I suggest you start another thread with appropriate subject. It helps others during the search process if they have similar problems.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  16. #16
    zFollette is offline ▼ dafuq did I do?
    Join Date
    Dec 2013
    Posts
    203
    Rep Power
    0

    Default Re: I want to know the flow

    Quote Originally Posted by jomajoms View Post
    Thanks, by the way I'm now doing my ATM machine program and I'm confused in using showConfirmDialog in JOptionPane. can you explain it? I'm done parsing it and it is stated that it requires: String , Found: Int.
    I would not see the need for parsing showConfirmDialog into a String, as it returns an int. Here is how I would handle it.

    Java Code:
    int i = JOptionPaine.showConfirmDialog();
    
    if (i == JOptionPane.YES_OPTION) {
    //do stuff
    } else if (i == JOptionPane.NO_OPTION) {
    //do stuff
    } else {
    //This is called when the dialog is canceled or exited
    }
    You could even use a switch case statement. Go crazy.
    jomajoms likes this.

  17. #17
    jomajoms is offline Member
    Join Date
    Dec 2013
    Posts
    10
    Rep Power
    0

    Default Re: I want to know the flow

    Thanks zFollette :) I could use this in making my other program.

  18. #18
    jomajoms is offline Member
    Join Date
    Dec 2013
    Posts
    10
    Rep Power
    0

    Default Re: I want to know the flow

    I have a problem in using JPanel, and I am trying to use it in my program
    can someone explain it to my how to use it and what needed to use and make it run.
    Thanks in advance.

    Regards,
    JomaJoms

  19. #19
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,656
    Rep Power
    5

    Default Re: I want to know the flow

    Please don't use this thread for that at they are unrelated topics. And also, please use meaningful subjects. So start a new thread for this topic (they're free).

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Flow of Basic example
    By suhaas.mohandos@gmail.com in forum Spring
    Replies: 6
    Last Post: 08-08-2013, 06:14 AM
  2. Replies: 6
    Last Post: 05-15-2013, 09:30 PM
  3. Web Service flow
    By sameerk in forum Web Frameworks
    Replies: 1
    Last Post: 05-06-2011, 09:56 AM
  4. Anyone use flow charts?
    By Java_Lover in forum New To Java
    Replies: 4
    Last Post: 04-09-2011, 02:27 PM
  5. How to generate Data Flow Diagram(Work Flow Diagram)
    By stsivaraj in forum AWT / Swing
    Replies: 1
    Last Post: 12-22-2010, 11:21 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •