LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-14-2006, 05:32 PM   #1
JerryV
LQ Newbie
 
Registered: Feb 2006
Posts: 1

Rep: Reputation: 0
Java printformat question


i had several questions related to the printf(%*) deal, and well i had this weird question on one of my tests last saturday that wanted to know the outcome of
Code:
int x = 2, y = 3;
System.out.printf("%02d%-2d", x, y);
the questions just requiers the output, but when i try to compile it, i cant; i think im doing something wrong with the class's, if someone could more or less explain to me about what it means, i'd really appreciate
 
Old 02-14-2006, 05:57 PM   #2
spooon
Senior Member
 
Registered: Aug 2005
Posts: 1,755

Rep: Reputation: 51
Why can't you compile it? What errors did it give?

I compiled it fine, and it output "023".
 
Old 02-14-2006, 11:31 PM   #3
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Perhaps you have JDK 1.4.2 or earlier?

Hi -

"printf" was only introduced in the most recent version, Java 5.0 (aka JDK 1.5.0). If you have an older version, you'll get a compiler error.

You can determine your version by typing "javac -version".

You can download the latest/greatest JDK from Sun's web site:
http://java.sun.com

'Hope that helps .. PSM
 
Old 02-16-2006, 08:30 AM   #4
cigarstub
Member
 
Registered: Sep 2005
Posts: 145

Rep: Reputation: 15
wat %02%-2d mean?
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Question k1ll3r_x Programming 2 08-20-2005 08:10 PM
Java question biojayc Linux - Newbie 8 03-22-2005 03:42 PM
java question zaicheke Programming 5 02-15-2005 12:40 PM
Question about Java Mega Man X Programming 3 12-27-2003 11:02 AM
java question TommyD Linux - Newbie 4 07-19-2003 04:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration