- Apr 26, 2004
- 1,078
- 282
- 136
Hello,
I am attempting exercise number #2 at: http://www.learnjavaonline.org/en/Variables_and_Types
The exercise at the end is:
Create all the the primitives with different values. Concatenate them into a string and print it to the screen so it will print: H3110 w0r1d 2.0 true
This is the code I have wrote:
My resulting output is: 113 w0r1d 2.0 true
I can't figure out what is breaking down in the first word that is supposed to be: H3110
Any ideas?
I am attempting exercise number #2 at: http://www.learnjavaonline.org/en/Variables_and_Types
The exercise at the end is:
Create all the the primitives with different values. Concatenate them into a string and print it to the screen so it will print: H3110 w0r1d 2.0 true
This is the code I have wrote:
Code:
public class Main {
public static void main(String[] args) {
byte zero = 0;
short firstwordnumericfirsthalf = 31;
int secondwordnonzeronumeric = 1;
long firstwordnumericsecondhalf = 10;
float twopointo = 2.0f;
double auxzero = 0.0f;
boolean lastword = true;
char one = 'H';
char two = 'w';
char three = 'r';
char four = 'd';
String output = one + firstwordnumericfirsthalf + firstwordnumericsecondhalf + " " + two + zero + three + secondwordnonzeronumeric + four + " " + twopointo + " " + lastword;
System.out.println(output);
}
}
My resulting output is: 113 w0r1d 2.0 true
I can't figure out what is breaking down in the first word that is supposed to be: H3110
Any ideas?
