Spandan Pandey

Greenhorn
+ Follow
since Feb 20, 2013
Merit badge: grant badges
For More
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
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Spandan Pandey

I ran this program,it compiled but nothing happened.

Would love your help!!Thanks!!
10 years ago


Output:-
TestFormats.java:4: cannot find symbol
symbol: class Date
location: class TestFormats
String s = String.format("%tr", new Date( ) );

1 error


Please Help!!!
10 years ago
I did some corrections and the .java file compiled without any error but the error began in the output
Here is my code..Is My conversion of the int random numbers into string and using in checkyourself method is wrong?If not then why the output error..the program gets stuck asking-enter the number perpetually.
10 years ago

Jeff Verdegan wrote:All the imports in a .java file have to go at the top of that file. The only thing that can come before them is the package statement and comments.

This is why the error message says, "class,interface or enum expected." Those are the only things that can appear where you've put that import statement.

Pay close attention to the error messages, they usually tell you exactly what's wrong, even if it's not immediately obvious at first glance what they're saying.


I understood you and did that.I did some corrections and the .java file compiled without any error but the error began in the output
Here is my code..Is My conversion of the int random numbers into string and using in checkyourself method is wrong?If not then why the output error..the program gets stuck asking-enter the number perpetually.
10 years ago
Using the new and improve DotComClass an error is coming at the command prompt like this.Can you please tell me how to get rid of that error.
Error:
SimpleDotCom.java:18:class,interface or enum expected
import java.util.ArrayList;
^
1 Error

My Code:
10 years ago

Ulf Dittmer wrote:Import statement must be at the beginning of a source file, not somewhere in the middle of it. Also note that Java is case-sensitive - there are a few compilation errors where you mixed up upper- and lowercase.



Thanks Ulf!!
It runs now!!I put the gamehelper at the beginning,corrected the UpperCase and LowerCase errors and now it runs alright!!
10 years ago
Hi Guys!!I need a serious help..I have stuck on this chapter for couple of days and now the program doesn't run.The javac compiler is showing this error at the command prompt:
SimpleDotCom.java:57:class,interface or enum expected
import java.io.*;
^
1 error


Here is my code:



10 years ago

Campbell Ritchie wrote:You ought to use code tags, but I have added them for yoiu. Coloured text doesn’t work inside code tags. It looks a lot better () and would have been better still with correct indentation.
Is that example from Head First Java? Which page? Have you copied it correctly? I am sure Sierra & Bates would never use == true, and neither should you; it is poor style and error‑prone in case you write = by mistake.
The idea of the condition is to show that the bangbang‑a‑bang method is not called when that flag is set to false. In line 3 it becomes true, and later (line 15) it becomes false.



Yeah,it's from head first java.Pg 46..it's from an exercise code magnets!!
so,what should one use instead of "== true"?

Thanks I didn't know how to use code tags that time.
11 years ago
Hi guys!!
I was just having trouble understanding how the boolean works in Java.I am not really getting the logic..the idea is a bit vague.I would be glad if you made it a bit clear for a novice like me.
For example in this program:

11 years ago
I am having a problem in the page 39 guessing game in Headfirst Java.
The command prompt is
GameLauncher.java:1: class GuessGame is public, should be declared in a file nam
ed GuessGame.java
public class GuessGame {
^
GameLauncher.java:65: class Player is public, should be declared in a file named
Player.java
public class Player {
^

So, I separately made .java file containing GuessGame class and Player classs and compiled it.
But still the GameLauncher.java isn't able to compile showing the same error.I don't understand the reason.Now I have separate class files for each of them,it must compile now.
Help!!
11 years ago