Learning Java Programming on Linux - Printable Version +- Linux Lite Forums (https://www.freecinema2022.gq/forums) +-- Forum: Development (https://www.freecinema2022.gq/forums/forumdisplay.php?fid=7) +--- Forum: Coding (https://www.freecinema2022.gq/forums/forumdisplay.php?fid=33) +--- Thread: Learning Java Programming on Linux (/showthread.php?tid=4284) Pages:
1
2
|
Learning Java Programming on Linux - Homework - 07-23-2017 Hello, I'm new to Linux Lite OS and programming. At the moment, I'm learning Java programming from a course at Udemy and I've encountered a problem with empty spaces in outputs. Here's part of the codes: Code: public String toString() Then I compiled the codes and here's what it's shown on the Terminal: Code: mei@mei-Aspire-4750:~/Documents/java$ javac NameTest.java All the spaces are appearing right before the name. I'm using Linux's Text Editor. Could this the reason why the codes are not working properly? Re: Learning Java Programming on Linux - bitsnpcs - 07-23-2017 I don't know how to write Java, have you tried changing - Code: last;} change to Code: last}; Re: Learning Java Programming on Linux - Homework - 07-24-2017 Hello bitsnpcs, thank you so much for replying to almost all my posts. Unfortunately this error message appeared when I tried changing the position of the semicolon: Code: Name.java:39: error: ';' expected This course is conducted using Windows OS, notepad, and CMD. Since my Windows OS crashed unexpectedly, I decided to carry on the course on Linux Lite. There are other web resources out there that recommended Vim, emacs or DrJava to learn Java on Linux platform, so I just want to confirm if this issue is really because I'm using Lite's text editor. Re: Learning Java Programming on Linux - bitsnpcs - 07-24-2017 Hello Homework, Hopefully someone will answer you soon about this. Linux Lite is more stable than Windows, it will be good for your course learning, once the issue is solved. I looked at the Udemy where you learn, I liked the beginners Ethical Hacker course contents, it is not free though. Re: Learning Java Programming on Linux - firenice03 - 07-24-2017 Giving it a quick look... The part listed... Code: new Name("Cookie" + "Monster" + "Jr") Maybe try, see if it results properly Code: new Name("Cookie " + "Monster " + "Jr") Re: Learning Java Programming on Linux - justme2 - 07-24-2017 I'm not familiar with java either, but one thing springs to mind - I think windows and linux use different line terminators in text editors, CRLF and LF. Could that be the problem? Re: Learning Java Programming on Linux - Homework - 07-25-2017 (07-24-2017, 02:34 PM)bitsnpcs link Wrote: I looked at the Udemy where you learn, I liked the beginners Ethical Hacker course contents, it is not free though. My cousin was sponsored by her company to take this course recently, and we have a laugh at it thinking how is hacking ever ethical! ;D But jokes aside, my course isn't free as well...... Re: Learning Java Programming on Linux - Homework - 07-25-2017 (07-24-2017, 05:29 PM)firenice03 link Wrote: Giving it a quick look... The part listed... Hello firenice03, thank you for your suggestion. It did work, but there are still extra empty spaces that appeared in front of the name due to the toString method. newName is supposed to appear as indicated by the toString method which has a space in between first, middle, and last name. The idea of the exercise is to to input each name alone without any spaces just like anyone filling up a field on a form etc., that's why toString method is used. There are two Java files and they both worked together, and here's the first set of code (called Name.java) that sets the foundation (if that's how programmer(s) put it?): Code: public class Name And here's the other file that has the data called NameTest.java: Code: public class NameTest NameTest.java would not work without Name.java. These are the two files in their entirety. Hope this would give clarity to what the codes are supposed to do. Re: Learning Java Programming on Linux - Homework - 07-25-2017 (07-24-2017, 07:53 PM)justme2 link Wrote: I'm not familiar with java either, but one thing springs to mind - I think windows and linux use different line terminators in text editors, CRLF and LF. Could that be the problem? Hello justme2, thank you for pointing out the difference! So I found this article: https://blog.codinghorror.com/the-great-newline-schism/, unfortunately I'm still none the wiser on how this would affect Lite text editor processing the empty spaces. Windows text editor save encoding as ANSI, while Lite text editor save encoding as UTF-8. Could this be the reason for this problem? Re: Learning Java Programming on Linux - justme2 - 07-25-2017 (07-25-2017, 03:19 PM)Homework link Wrote: [quote author=justme2 link=topic=4444.msg33814#msg33814 date=1500925986] Hello justme2, thank you for pointing out the difference! So I found this article: https://blog.codinghorror.com/the-great-newline-schism/, unfortunately I'm still none the wiser on how this would affect Lite text editor processing the empty spaces. Windows text editor save encoding as ANSI, while Lite text editor save encoding as UTF-8. Could this be the reason for this problem? [/quote] I have no idea if that is the problem, but the text editor I use (Leafpad) has an option to set the required line terminator to CRLF or just LF. I can only suggest trying it as I do not use Java. |