• Post Reply Bookmark Topic Watch Topic
  • New Topic

Composition program getting exception  RSS feed

 
Adam Chalkley
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys I just recently got the hang of composition what it is and how it's used I wrote a simple program to display the age and name of a person BUT it compiles fine no compiler errors but when I run the program I get an exception and this is what the exception is

exception in thread "main" java.util.illegalFormatConversionException: d != r3
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2747)

at java.util.Formatter$FormatSpecifier.print(Formatter.java:2520)

...

there is about another 9 "ats" following the two above.

here's my code



second class




main




How would I "fix" this conversion error(I've studied a little of exceptionhandling but not much just touched on it before so don't know the details,so without throwing or declaring exceptions how would I try to fix this)

Thanks
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Somewhere you are using a % tag for printf (or similar) which does not match its argument.
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adam Chalkley wrote:
there is about another 9 "ats" following the two above.


And as you go down the list of stack calls, it will get to the point in the stacktrace where it is in your code that triggered it. This should help you isolate the location of the exception.

Henry
 
Knute Snortum
Sheriff
Posts: 4281
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is here:



The variable age is not an integer; it contains an integer. How would you access the integer in the r3 class?
 
Adam Chalkley
Ranch Hand
Posts: 518
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:The problem is here:



The variable age is not an integer; it contains an integer. How would you access the integer in the r3 class?



Thanks ok well I found the problem but using the String.format method or system.prinntf what does the %d and the %s stand for and what do they do?I'm just copying this from what I seen from a tutorial.

scratch that ^^ all good and sorted something new learned lol thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!