John Delmark Aguilar

Delmark - Profiling
 
HomeCalendarFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 Displaying Syntax System.out.print

View previous topic View next topic Go down 
AuthorMessage
dElmARk
Admin
Admin
avatar

Posts : 92
Join date : 09/04/2012

PostSubject: Displaying Syntax System.out.print   Tue Oct 23, 2012 1: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
View user profile http://delmark.meabout.com
dElmARk
Admin
Admin
avatar

Posts : 92
Join date : 09/04/2012

PostSubject: Re: Displaying Syntax System.out.print   Tue Oct 23, 2012 1: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
View user profile http://delmark.meabout.com
dElmARk
Admin
Admin
avatar

Posts : 92
Join date : 09/04/2012

PostSubject: Re: Displaying Syntax System.out.print   Tue Oct 23, 2012 1: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
View user profile http://delmark.meabout.com
Sponsored content




PostSubject: Re: Displaying Syntax System.out.print   

Back to top Go down
 
Displaying Syntax System.out.print
View previous topic View next topic Back to top 
Page 1 of 1

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