wood burning stoves*
The moose likes Beginning Java and the fly likes Problem typing examples Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem typing examples" Watch "Problem typing examples" New topic
Author

Problem typing examples

apostolos kikirikou
Greenhorn

Joined: Jan 12, 2013
Posts: 4
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

Joined: Oct 01, 2001
Posts: 2851
    
  11

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

Joined: Oct 02, 2003
Posts: 11320
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
apostolos kikirikou
Greenhorn

Joined: Jan 12, 2013
Posts: 4
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.


[Download rsz_11.bmp] Download

apostolos kikirikou
Greenhorn

Joined: Jan 12, 2013
Posts: 4
attachment


[Download rsz_212.bmp] Download

Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
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

Joined: Oct 13, 2005
Posts: 38896
    
  23
Agree: this link has another link in, explaining how to post text from a command prompt.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11320
    
  16

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

Joined: Oct 13, 2005
Posts: 38896
    
  23
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

Joined: Jan 12, 2013
Posts: 4
Thanks for your help i just now started to learn Java and i needed some help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem typing examples