<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: java.util.IllegalFormatConversionException when using System.out.format()</title>
	<atom:link href="http://dobrzanski.net/2008/05/02/javautilillegalformatconversionexception-when-using-systemoutformat/feed/" rel="self" type="application/rss+xml" />
	<link>http://dobrzanski.net/2008/05/02/javautilillegalformatconversionexception-when-using-systemoutformat/</link>
	<description>The blog for developers</description>
	<lastBuildDate>Sun, 05 Feb 2012 21:35:36 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Monu</title>
		<link>http://dobrzanski.net/2008/05/02/javautilillegalformatconversionexception-when-using-systemoutformat/comment-page-1/#comment-81910</link>
		<dc:creator>Monu</dc:creator>
		<pubDate>Mon, 31 Jan 2011 12:17:30 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=85#comment-81910</guid>
		<description>import java.io.*;
class DemoReadline
{
public static void main(String args[]) throws IOException
{
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println(&quot;enter id of the employee&quot;);
int id = Integer.parseInt(br.readLine());
System.out.println(&quot;enter sex of the employee&quot;);
char ch=(char)br.read();
System.out.println(&quot;enter name of the employee&quot;);
String name= br.readLine();
System.out.printf(&quot;num=%d%nchar=%c%nString=%s%n&quot;+id,ch,name);
}
} wats the right syntax here,,,can anybody help me out....am a learner of java...its the exception...enter id of the employee
2
enter sex of the employee
m
enter name of the employee
num=Exception in thread &quot;main&quot; java.util.IllegalFormatConversionException: d != java.lang.Character
	at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
	at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source)
	at java.util.Formatter$FormatSpecifier.print(Unknown Source)
	at java.util.Formatter.format(Unknown Source)
	at java.io.PrintStream.format(Unknown Source)
	at java.io.PrintStream.printf(Unknown Source)
	at DemoReadline.main(DemoReadline.java:13)</description>
		<content:encoded><![CDATA[<p>import java.io.*;<br />
class DemoReadline<br />
{<br />
public static void main(String args[]) throws IOException<br />
{<br />
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));<br />
System.out.println(&#8220;enter id of the employee&#8221;);<br />
int id = Integer.parseInt(br.readLine());<br />
System.out.println(&#8220;enter sex of the employee&#8221;);<br />
char ch=(char)br.read();<br />
System.out.println(&#8220;enter name of the employee&#8221;);<br />
String name= br.readLine();<br />
System.out.printf(&#8220;num=%d%nchar=%c%nString=%s%n&#8221;+id,ch,name);<br />
}<br />
} wats the right syntax here,,,can anybody help me out&#8230;.am a learner of java&#8230;its the exception&#8230;enter id of the employee<br />
2<br />
enter sex of the employee<br />
m<br />
enter name of the employee<br />
num=Exception in thread &#8220;main&#8221; java.util.IllegalFormatConversionException: d != java.lang.Character<br />
	at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)<br />
	at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source)<br />
	at java.util.Formatter$FormatSpecifier.print(Unknown Source)<br />
	at java.util.Formatter.format(Unknown Source)<br />
	at java.io.PrintStream.format(Unknown Source)<br />
	at java.io.PrintStream.printf(Unknown Source)<br />
	at DemoReadline.main(DemoReadline.java:13)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janzeh</title>
		<link>http://dobrzanski.net/2008/05/02/javautilillegalformatconversionexception-when-using-systemoutformat/comment-page-1/#comment-57563</link>
		<dc:creator>janzeh</dc:creator>
		<pubDate>Tue, 16 Nov 2010 22:30:45 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=85#comment-57563</guid>
		<description>thaaaanks, my friend got an error and i couldnt figure what he had done wrong :D i knew it had something to do with the double.</description>
		<content:encoded><![CDATA[<p>thaaaanks, my friend got an error and i couldnt figure what he had done wrong <img src='http://dobrzanski.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  i knew it had something to do with the double.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Raja Nagendra Kumar</title>
		<link>http://dobrzanski.net/2008/05/02/javautilillegalformatconversionexception-when-using-systemoutformat/comment-page-1/#comment-28071</link>
		<dc:creator>Raja Nagendra Kumar</dc:creator>
		<pubDate>Mon, 28 Dec 2009 12:22:22 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=85#comment-28071</guid>
		<description>As a addendum to the same error, we see the following can happen due to lack of conversion from long to float.

for a code like this

boolean lInMBSize = (sizeCount / CommonConst.MEGA_BYTES) &gt; 0;
	StringBuffer sb = new StringBuffer();
	Formatter fm = new Formatter(sb);
	fm.format(&quot;\n%-16s\t%-6d\t%15.2f %s\t%-16d&quot;,
		  ext,
		  fileCount,
		  lInMBSize ?
		  (sizeCount / CommonConst.MEGA_BYTES) :
		  (sizeCount / CommonConst.KB_BYTES),
		  lInMBSize ? &quot;MB&quot; : &quot;kb&quot;,
		  lineCount);
	return sb.toString();

We are seeing similar error in this case for converting long to float..the value of long passed is 2..

Hope long to be convertible to float as they are compatible.


java.util.IllegalFormatConversionException: f != java.lang.Long
        at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:399
9)
        at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2722)
        at java.util.Formatter$FormatSpecifier.print(Formatter.java:2667)
        at java.util.Formatter.format(Formatter.java:2433)
        at java.util.Formatter.format(Formatter.java:2367)
        at com.tejasoft.ant.common.cm.CMInfo.toString(CMInfo.java:99)
        at java.lang.String.valueOf(String.java:2826)</description>
		<content:encoded><![CDATA[<p>As a addendum to the same error, we see the following can happen due to lack of conversion from long to float.</p>
<p>for a code like this</p>
<p>boolean lInMBSize = (sizeCount / CommonConst.MEGA_BYTES) &gt; 0;<br />
	StringBuffer sb = new StringBuffer();<br />
	Formatter fm = new Formatter(sb);<br />
	fm.format(&#8220;\n%-16s\t%-6d\t%15.2f %s\t%-16d&#8221;,<br />
		  ext,<br />
		  fileCount,<br />
		  lInMBSize ?<br />
		  (sizeCount / CommonConst.MEGA_BYTES) :<br />
		  (sizeCount / CommonConst.KB_BYTES),<br />
		  lInMBSize ? &#8220;MB&#8221; : &#8220;kb&#8221;,<br />
		  lineCount);<br />
	return sb.toString();</p>
<p>We are seeing similar error in this case for converting long to float..the value of long passed is 2..</p>
<p>Hope long to be convertible to float as they are compatible.</p>
<p>java.util.IllegalFormatConversionException: f != java.lang.Long<br />
        at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:399<br />
9)<br />
        at java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:2722)<br />
        at java.util.Formatter$FormatSpecifier.print(Formatter.java:2667)<br />
        at java.util.Formatter.format(Formatter.java:2433)<br />
        at java.util.Formatter.format(Formatter.java:2367)<br />
        at com.tejasoft.ant.common.cm.CMInfo.toString(CMInfo.java:99)<br />
        at java.lang.String.valueOf(String.java:2826)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tahir</title>
		<link>http://dobrzanski.net/2008/05/02/javautilillegalformatconversionexception-when-using-systemoutformat/comment-page-1/#comment-27895</link>
		<dc:creator>Tahir</dc:creator>
		<pubDate>Thu, 24 Dec 2009 10:10:01 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=85#comment-27895</guid>
		<description>Thanks, It is much clear and to the point.
Precise and concise without any unnecessary stuff</description>
		<content:encoded><![CDATA[<p>Thanks, It is much clear and to the point.<br />
Precise and concise without any unnecessary stuff</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: deval mathur</title>
		<link>http://dobrzanski.net/2008/05/02/javautilillegalformatconversionexception-when-using-systemoutformat/comment-page-1/#comment-11289</link>
		<dc:creator>deval mathur</dc:creator>
		<pubDate>Mon, 17 Nov 2008 06:46:33 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=85#comment-11289</guid>
		<description>it was helpful....
i was struck at it at one point....gud</description>
		<content:encoded><![CDATA[<p>it was helpful&#8230;.<br />
i was struck at it at one point&#8230;.gud</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jeff</title>
		<link>http://dobrzanski.net/2008/05/02/javautilillegalformatconversionexception-when-using-systemoutformat/comment-page-1/#comment-5694</link>
		<dc:creator>Jeff</dc:creator>
		<pubDate>Fri, 13 Jun 2008 00:44:01 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=85#comment-5694</guid>
		<description>Thanks soooooooooooo much Jarosław for this very helpful help.</description>
		<content:encoded><![CDATA[<p>Thanks soooooooooooo much Jarosław for this very helpful help.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

