I'm trying to write an example program to help me better understand java but the problem is Eclipse will only print out whatever is in System.out.println()
for one line of code and not all of them.
class MyClass {
public static void main(String[] args){
System.out.println("I am learning Java");
System.out.println("Hello World");
String fruit = "apple";
int sea =1;
double goaldifference = 2.54;
System.out.println(fruit);
System.out.println(sea);
System.out.println(goaldifference);
} //this line of code is printed to the console
{
int a , b , c;
a =4;
b =6;
c = a+b;
System.out.println(c);
int hen =17;
System.out.println(++hen);
}//this line of code isn't printed to the console
{
int test = 6;
if (test == 9){
System.out.println("yes");
}else{
System.out.println("no");
if (test != 8){
System.out.println("no");
}else{
System.out.println("try different number");
}
int age = 14;
if(age < 16){
System.out.println("still in high school");
}else if (age > 16){
System.out.println("in college");
}//this line of code isn't printed to the console
}
}
Eclipse doesn't flag up anything as being wrong and I don't get any errors when printing to the console it's just that my second and third lines of code print nothing to the console for whatever reason. I removed some single and multi line comments from the text but the code remains unedited in the pictures thanks for the help and sorry if my code looks confusing.