# Thread: I want to know the flow

1. Member
Join Date
Dec 2013
Posts
10
Rep Power
0

## 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. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,154
Rep Power
12

## Re: I want to know the flow

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

Regards,
Jim

3. ## 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.

4. Member
Join Date
Dec 2013
Posts
10
Rep Power
0

## 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. Member
Join Date
Dec 2013
Posts
10
Rep Power
0

## Re: I want to know the flow

Thanks surfMan

6. Just a guy
Join Date
Jun 2013
Location
Netherlands
Posts
5,114
Rep Power
10

## Re: I want to know the flow

Originally Posted by jomajoms
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.

7. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,154
Rep Power
12

## 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 04:34 PM.

8. Member
Join Date
Dec 2013
Posts
10
Rep Power
0

## 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. Member
Join Date
Dec 2013
Posts
10
Rep Power
0

## 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. Member
Join Date
Dec 2013
Posts
10
Rep Power
0

## 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 05:11 AM. Reason: Missing word

11. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,154
Rep Power
12

## 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

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 05:57 AM.

12. Member
Join Date
Dec 2013
Posts
10
Rep Power
0

## 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 11:26 AM. Reason: incorrect name

13. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,154
Rep Power
12

## 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

14. Member
Join Date
Dec 2013
Posts
10
Rep Power
0

## 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. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,154
Rep Power
12

## 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

16. ▼ dafuq did I do?
Join Date
Dec 2013
Posts
204
Rep Power
0

## Re: I want to know the flow

Originally Posted by jomajoms
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.

17. Member
Join Date
Dec 2013
Posts
10
Rep Power
0

## Re: I want to know the flow

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

18. Member
Join Date
Dec 2013
Posts
10
Rep Power
0

## 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.

Regards,
JomaJoms

19. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,154
Rep Power
12

## 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