• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

New Boston tutorial #16 - getting an error

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using the NewBoston tutorials and have come across an error. After checking it over time and time again, my code is exactly the same (I think). I cannot find out where I went wrong. It is in two classes, here is the code:




classOne code


The error is :
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, String)

at classOne.saying(classOne.java:12)
at mainClass.main(mainClass.java:13)
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code looks ok to me.
How are you compiling this code?
What version of java are you using?
Are you using the standard sun java compiler/runtime ?



 
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as per javadoc usage is correct. May be problem is with your version as Stefan mentioned.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recommend you steer clear of NewBoston and find someone/something else to learn from:

http://www.reddit.com/r/learnprogramming/comments/11ubro/28_ways_to_learn_programming/c6pwzdn

http://www.reddit.com/r/learnprogramming/comments/11ubro/28_ways_to_learn_programming/c6ppc38

 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Holcomb wrote:I recommend you steer clear of NewBoston


I agree, I've watched his tutorials, he never explains anything, he just shows you what to do, so when something breaks you have no clue why.
 
Marshal
Posts: 75836
361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very peculiar error.

Go and hunt for the Java┬« Language Specification (=JLS) and go through it looking for “varargs”. What is happening is that printf takes a varargs of Objects after the format String and it turns those arguments into an array. If you write the identifier for a single String there (remember that there is only one format String because the compiler joins the two halves with the + operator): girlName
System.out.printf("You have spent years trying to forget %s and this daft%n" +
    "program insists on reminding you of her.%n", girlName);
… then the compiler interprets that as a one‑element array. Obviously if you pass the name of a method, the compiler sees that as a single argument, which in this case is of type String. Did it say anything helpful in the JLS about that? I have never seen that particular compiler error before.

Edit: Add this warning. The JLS can be very difficult to read.
 
Patrick De
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone recommend a better set of videos online?
 
Tushar Goel
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try this or CS106A from standford. For CS106A several videos are available online free. For first course, i have not checked
specifically this course but i took another courses. Instructor is looking good to me. This beginning course is free.
 
David Holcomb
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David De wrote:Can someone recommend a better set of videos online?



https://www.youtube.com/playlist?list=PLE7E8B7F4856C9B19 (Derek Banas)
https://www.youtube.com/playlist?list=PL9DF6E4B45C36D411 (CaveOfProgramming)

 
Tushar Goel
Ranch Hand
Posts: 954
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i dont know about first but 2nd one i already recommended to you.
 
David Holcomb
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tushar Goel wrote:i dont know about first but 2nd one i already recommended to you.



LOL we're different people. I can understand why you thought we were the same. You thought we were the same because you only saw the first name which is "David."
 
reply
    Bookmark Topic Watch Topic
  • New Topic