• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem typing examples

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello i m new in this forum.I m trying to type some Java examples on Eclipse but i have many errors.When i copy paste the same example onn Eclipse i get no errors and the program runs normal.
 
Sheriff
Posts: 3063
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

We need more details from you. Assuming you are typing and pasting the same examples, and the typed ones don't work, then that would mean you are making some typing errors. If you show us the program, and the errors you are getting, we can help point you in the right direction.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, this is a good way to learn.

Yes, it is a pain, but eventually you start learning things like "String" is not the same as "string". It really does teach you to be more careful when you code.

When you do get errors, the best thing to do is to fix the first one, and then recompile. A lot of errors mask others, or make the compiler think there are more than there really are. So, fix the first one, and see what's left.
 
apostolos kikirikou
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have typed an example with differences in days between 2 days.I get errors on Print in stream methods.The method is undefined for the method print Stream.
If i delete my typed statements and paste those from the example 's source code the errors disappear .Or i have to folllow Eclipse to rename to PrintIn.
Filename: rsz_11.bmp
File size: 768 Kbytes
 
apostolos kikirikou
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
attachment
Filename: rsz_212.bmp
File size: 768 Kbytes
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is not forcibly a good idea to post screen shots. Who is willing to take the extra fuzz to see them?
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Agree: this link has another link in, explaining how to post text from a command prompt.
 
fred rosenberger
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

apostolos kikirikou wrote:I have typed an example with differences in days between 2 days.I get errors on Print in stream methods.The method is undefined for the method print Stream.
If i delete my typed statements and paste those from the example 's source code the errors disappear .Or i have to folllow Eclipse to rename to PrintIn.


There is no such method as PrintIn. You can look at the java API to see what methods do and don't exist.

If you are trying to print some text to the screen, you should use

System.out.println()

Note: the LOWERCASE 'p'. also, it is a LOWERCASE 'l' (the letter between k and m), not an uppercase "I". It stands for something line "print with a new line".

This is a textbook case of why you should compile more often. Personally, I would have compiled after writing the first print statement. If it worked, great, I'd then add the next one. If it didn't, I'd fix it, only having to worry about ONE error. Then I'd use what I learned, and not make the same mistake on the next statement.

yes, it can be a slow, painful process. I can't tell you how many times I made the semi-colon-on-my-for-line-mistake:


This will not print ten lines, but one. The error is subtle, and I made it over and over. But once I REALLY learned it, I never made it again.
 
Campbell Ritchie
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would have been better to declare the loop variable (x) after the keyword for. Then it would have gone out of scope before the println call and your code would not have compiled. You might still have taken ages to find the wayward ; however.
 
apostolos kikirikou
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help i just now started to learn Java and i needed some help.
 
Fire me boy! Cool, soothing, shameless self promotion:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic