You are Here:
Linux Lite 6.2 RC1 Released - See Release Announcements



Learning Java Programming on Linux

Author (Read 13003 times)

0 Members and 2 Guests are viewing this topic.

Re: Learning Java Programming on Linux
« Reply #2 on: July 23, 2017, 06:05:37 AM »
 

bitsnpcs

  • Platinum Level Poster
  • **********
  • 3237
    Posts
  • Reputation: 305
    • Try to Grow

  • Linux Lite: 3.2 64bit

  • Kernel: 4.x
I don't know how to write Java, have you tried changing -
Code: [Select]
last;} 
change to 
Code: [Select]
last};
« Last Edit: July 23, 2017, 06:34:11 AM by bitsnpcs »
 

Learning Java Programming on Linux
« Reply #1 on: July 23, 2017, 04:55:01 AM »
 

Homework

  • New to Forums
  • *
  • 16
    Posts
  • Reputation: 2
  • Linux Lite Member

  • Linux Lite: 3.2 64bit

  • CPU: Intel(R) Core(TM) i5-2410M CPU @ 2.30GHz

  • MEMORY: 6Gb
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: [Select]
public String toString()   
{
        return first + " " + middle + " " + last;   
}

Name myName = new Name("Cookie" + "Monster" + "Jr");
System.out.println("myName: " + myName.toString());

Then I compiled the codes and here's what it's shown on the Terminal:
Code: [Select]
[email protected]:~/Documents/java$ javac NameTest.java
[email protected]:~/Documents/java$ javac Name.java
[email protected]:~/Documents/java$ java NameTest
myName:   CookieMonsterJr

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?
« Last Edit: July 25, 2017, 10:48:45 AM by Homework »
 

 

-->
X Close Ad

Linux Lite 6.2 RC1 Released - See Release Announcements