Go Back   Computer Forums > General Computing > Programming
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 06-21-2009, 12:43 AM   #1
(╯□)╯︵ ┻━┻
Teny's Avatar
Join Date: Dec 2006
Location: United States
Posts: 5,957
Default Java questions

What does "%s" mean? what does it do?
I see it in the coding of the display message.

Desktop -Cooler Master NV690/AMD Phenom II X4 965 BE/MSI 880G-E45 Motherboard/2 x 2GB DDR3 G.Skill Ripjaws X/Sapphire HD 5870 1GB GDDR5/CORSAIR CMPSU-550VX/Seagate 7200.12 500GB (OS), Samsung F3 1TB (Storage)/Sony DVD Burner/Windows 7 Professional 64-bit
Teny is offline   Reply With Quote
Old 06-21-2009, 01:47 AM   #2
Beta Member
Join Date: Jun 2009
Posts: 1
Default Re: Java questions


"%s" is a format specifier for the printf function in Java language. The printf function accepts a format string, which specifies a method for displaying a number of parameters into a string. Any character in this string is displayed literally, and the parameters are placed in this string in positions marked by format specifiers, usually introduced by a % character.
Examples of format specifiers are:
- %s = string parameter
- %d = integer parameter
- %f = float parameter

So an example should look like this:

printf("The number you want to display is: %d",number);
printf("My name is %s and I'm %d years old.", name,age);
So if number=123 and name="George" and age=26, the output should be:
The number you want to display is: 123
My name is George and I am 26 years old.
I hope you understand something from this.
Have a nice day.

ITSupportQuotes is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 06:21 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2016, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0