small help about execution

Java programming topics
Post Reply
User avatar
Face
Major
Major
Posts: 727
Joined: Thu Feb 18, 2010 5:06 pm
Location: SRI LANKA.KANDY.

small help about execution

Post by Face » Wed Aug 18, 2010 7:29 pm

I found this question in one of my studding kit..I wanna find the out put of this...I tried with my favorite JAVA editor..It contains errors..

this is the small code

Code: Select all

class EditEx6{
	public static void main(String[] args){
		int a=5,b=4,c=7;
		System.out.printf("%3d%1$d%2$d",a,b,c);
		}
	}
when I compile this.There are no errors...

Code: Select all

>javac EditEx6.java
>Exit code: 0
Then I ran this program with the hope of getting the out put for my question.But Then I got errors or some kind of statements about some errors

This is it...

Code: Select all

>javac EditEx6.java
>Exit code: 0
>java -cp . EditEx6
Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '$'
	at java.util.Formatter.checkText(Unknown Source)
	at java.util.Formatter.parse(Unknown Source)
	at java.util.Formatter.format(Unknown Source)
	at java.io.PrintStream.format(Unknown Source)
	at java.io.PrintStream.printf(Unknown Source)
	at EditEx6.main(EditEx6.java:4)
>Exit code: 1
can you tell me what is wrong????
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: small help about execution

Post by Neo » Wed Aug 18, 2010 8:16 pm

Try following line.

Code: Select all

System.out.printf("%3d %1d %2d", a, b, c);
User avatar
Face
Major
Major
Posts: 727
Joined: Thu Feb 18, 2010 5:06 pm
Location: SRI LANKA.KANDY.

Re: small help about execution

Post by Face » Thu Aug 19, 2010 6:59 pm

got it..thnkz Neo
Post Reply

Return to “Java Programming”