My issue
i am unable to get the output
My code
class CodeChef
{
public static void main (String[] args)
{
// update your code here
System.out.println( 3 + 4);
System.out.println(2 + 1);
}
}
Learning course: Learn Java
Problem Link: CodeChef: Practical coding for everyone
@sreenidhi_188
The question states to print it together in the same line ,so you must use print not println
@sreenidhi_188
Let’s understand the differences first.
- The key difference between Java’s print and println methods is that println appends a newline character (‘\n’) to output, while Java’s print method does not.
- You can print it with using two print statements.
class CodeChef
{
public static void main (String[] args)
{
System.out.print(3 + 4);
System.out.print(2 + 1);
}
}
- Or you can just print in a single print statement.
class CodeChef
{
public static void main (String[] args)
{
System.out.print((3 + 4) + “” + (2 + 1));
}
}