• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem typing examples

 
apostolos kikirikou
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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.
 
Greg Charles
Sheriff
Posts: 2985
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • 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.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
Description:
File size: 750 Kbytes
[Download rsz_11.bmp] Download Attachment
 
apostolos kikirikou
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
attachment
Filename: rsz_212.bmp
Description:
File size: 750 Kbytes
[Download rsz_212.bmp] Download Attachment
 
Ivan Jozsef Balazs
Rancher
Posts: 979
5
  • Mark post as helpful
  • send pies
  • 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?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49361
62
  • Mark post as helpful
  • send pies
  • 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
Bartender
Posts: 12143
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Pie
Posts: 49361
62
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks for your help i just now started to learn Java and i needed some help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic