John Delmark Aguilar
Would you like to react to this message? Create an account in a few clicks or log in to continue.
John Delmark Aguilar

Personal Forum
 
HomeSearchLatest imagesRegisterLog in

 

 Displaying Syntax System.out.print

Go down 
AuthorMessage
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

Displaying Syntax System.out.print Empty
PostSubject: Displaying Syntax System.out.print   Displaying Syntax System.out.print Icon_minitimeTue Oct 23, 2012 8:49 pm

Statements Sample

Displaying Syntax


Code:
System.out.print(“[Message]”);
System.out.print(“[Message]”);

Output:
[Message][Message]


Code:
System.out.println(“[Message]”);
System.out.println(“[Message]”);

Output:
[Message]
[Message]



The difference of print and println
print - displays the content on the same line
println - displays the content on the next line
Back to top Go down
https://delmark.forumtl.com
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

Displaying Syntax System.out.print Empty
PostSubject: Re: Displaying Syntax System.out.print   Displaying Syntax System.out.print Icon_minitimeTue Oct 23, 2012 8:50 pm

Create a sample program:

Code:

class Pname{
public static void main(String [] args){
System.out.println("[Message]");
System.out.println("[Message]");
}
}


_____________

Save as Pname.java
Compiling and Running
1. Start then Run.
2. Type cmd (Press enter).
3. Go to the drive of your folder.
Ex: c: (Press enter)
4. Compile your program.
Ex: c Pname.java (Press enter).
5. Run the program.
Ex. r Pname (Press enter).


Note:
The 4 and 5 are your batch files
Link: [You must be registered and logged in to see this link.]
Back to top Go down
https://delmark.forumtl.com
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

Displaying Syntax System.out.print Empty
PostSubject: Re: Displaying Syntax System.out.print   Displaying Syntax System.out.print Icon_minitimeTue Oct 23, 2012 8:54 pm

Displaying Variable

Code:

VarType varName = content;
System.out.print(varname);


Sample:
String name = "Your name";
System.out.print(name);

Output:
Your name

________________
Displaying morethan one variable/message.

Sample:
Sting name = "Juan";
int age = 16;
System.out.print("Name: " + name + "Age: " + age);

Output:
Name: Juan Age: 16


Note: To concatinate(combine) a variable and strings use the plus sign (+). Beware of concatination, the plus (+) sign is a mathematical operator so if you do not want to concatinate 2 integer type, make sure that you first concatinate with string variable. Example (2+ " " +2)
Back to top Go down
https://delmark.forumtl.com
Sponsored content





Displaying Syntax System.out.print Empty
PostSubject: Re: Displaying Syntax System.out.print   Displaying Syntax System.out.print Icon_minitime

Back to top Go down
 
Displaying Syntax System.out.print
Back to top 
Page 1 of 1
 Similar topics
-
» Displaying Message
» Scanner Syntax
» BufferedReader Syntax
» ATM System
» Payroll System - DATA STRUCTURE

Permissions in this forum:You cannot reply to topics in this forum
John Delmark Aguilar :: dElmARk Productions :: Java Programs :: Tutorials-
Jump to: