Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!

Fergal Crawley

Greenhorn
+ Follow
since Nov 28, 2011
Fergal likes ...
Netbeans IDE Chrome Java
Co Louth, Ireland
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
14
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Fergal Crawley

Thanks for your help Jeff. I felt it was a different question because I used variables second time round. I wasn't aware that;

Jesper de Jong wrote:...The Java compiler performs an optimization with string literals. If the same string literal, for example "aa", is used multiple times in the same program, then the compiler makes sure that only one String object is created, which is reused...



Thanks for that Jesper. Also I hadn't seen some of the earlier replies (with the links) as they were written when I was replying with my second question.

Thanks again everyone, I understand it now.
8 years ago
Thanks for your replies. Given your explanations, I didn't expect the code below to work and output "Equal", but it does. Why is that?

8 years ago
It was my understanding that == should not be used for testing String equality. However, the code below works;



Why does that code work and output "Equal"?

Are there any circumstances where it is OK to use == to test for String equality?

Thanks!
8 years ago
I know what the statement below does:



However, I find it difficult to understand how it works in terms of objects and classes. Could anyone please explain how it works or post a link that would help me understand it?

Thanks!
9 years ago
Thanks everyone for your very helpful replies. I got the info I needed. Karthik Shiraly, your reply was particularly informative.
9 years ago
I know that this forum software is built using Java, however, most forum software (e.g. phpBB, vBulletin, IPB, etc) is built using PHP and MySQL. Most other website development scripts (such as image hosting scripts, classified ad scripts, blogs, CMSs, etc) also appear to be built with PHP.

Why are more websites not built with Java?

How do Java and PHP compare, when it comes to web development?

Does Java have any advantages over PHP, when it comes to web development?

Also it would be great if you could please post links to any quality websites built using Java.

Thanks!
9 years ago
Thanks everyone. Unfortunately my IDE doesn't show the " ^" symbol. I've been using an IDE for a little while now and find it easier than using a text editor and command line, so will probably stick with it at least for the moment.
9 years ago
Thanks for the replies, I might consider switching to Eclipse at some time to see if it provides better error reporting.
9 years ago
Thanks Campbell, I'm sure most programmers would be glad to see more helpful error messages.

I spent some time looking at that code without seeing the error. Would anyone have any tips on how to identify errors like that quicker?
9 years ago
Thanks Matthew, I see what I've done wrong by declaring the i variable at the end of the for statement. It was a stupid error that I just couldn't see.

Is there any way that I could have identified the exact cause of the error, from the error messages in Netbeans?
9 years ago
I'm a beginner and am learning how to use methods. The IDE I'm using is NetBeans.

Although I've spent a lot of time looking through the short program below, I can't figure out what's causing the errors in lines 13 and 14.



Could you please give me some suggestions as to how I can figure out what is causing these errors? I believe that the error is something very simple and really what I want to learn is how to go about finding the cause of those errors, rather than a solution for this particular program.

The error message from Netbeans is as follows;

run:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - not a statement
at liangch5.LiangCh5.sum(LiangCh5.java:14)
at liangch5.LiangCh5.main(LiangCh5.java:9)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)



Thanks!
9 years ago

Walter Ho wrote:...Aha. You're using a package.
Type in "cd C:\java\hello\src\" into the command line, it should output "C:\java\hello\src\" on the command line.
You then compile the code with "javac hello\Hello.java" on that command line, it just outputs ""C:\java\hello\src\" again, providing there are no compiler errors.
Now to run your code, you have use "java hello.Hello" to run the code....



Thanks Walter, that's exactly what I needed to do, problem solved

Thanks also Chris, I'll consider those unwanted file extensions should I run into any further problems.

I also came across a couple of useful articles that others with similar issues might find helpful.

Installing and Configuring JDK
Compiling and Running Java from the Command Window

9 years ago
Thanks for your help Walter. I have the JDK installed and have verified that it is configured correctly, using the command prompt.

When I type "cd C:\java\hello\src\hello\" into the command line, it outputs "C:\java\hello\src\hello\" on the command line. When I type "javac Hello.java" on that command line, it just outputs ""C:\java\hello\src\hello\" again, without running the program.

The program is the simple "Hello World!" one below, and at least I don't think it is being run from the command line.



Am I doing something wrong?

Thanks!
9 years ago
My PC runs on Windows XP. When I try to run a java program (written using NetBeans) from the command prompt, the program opens in NotePad but does not run.

This is what I have been typing at the command prompt:

C:\java\hello\src\hello\Hello.java



The above is the correct path to the Java file on my PC.

Can you please tell me how to run the program from the command prompt or perhaps link me to a tutorial that explains it?

Thanks!
9 years ago
Thanks Darryl, that worked. I've a lot to learn
9 years ago