write a program in java to print name and class in two different lines using print() method
Answers
Answered by
1
Required Answer:-
Question:
- Write a Java program to print name and class in two different lines using print() method.
Solution:
This is done in Java.
public class Info {
public static void main(String[] args) {
System.out.println("Name: name.");
System.out.println("Class: class.");
}
}
- println() function prints texts on the screen and moves to the next line however print() statement displays the texts on the screen and remain in the same line.
- After displaying the name, it will move to a new line and then, this program displays the class.
See the attachment for output ☑.
Attachments:
Similar questions