• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Very noobi question in Java

Joined
Jan 27, 2009
Messages
225 (0.04/day)
System Name Flash
Processor I5-4670K
Motherboard MSI Z87-G45
Cooling Stock Air
Memory 4x4GB G.Skill RipjawX DDR-1600 CL9
Video Card(s) ASUS 7970 DCU II
Storage Samsung 840 250GB + WD Black 640GB
Display(s) Dell U2412m + 2x Dell 2209WA
Case Corsair 230T
Audio Device(s) Realtek Hi-Def onboard
Power Supply HX850
Software Win7 Pro
So, I'm doing some sample exercises, and I have no idea why there is a compiler error on line 6

public class Awake {
public void Awake(String time){
System.out.println(“Time is “+time);
}
public static void main(String[] args){
Awake a = new Awake(“up!”); //ERROR HERE
}
}

Please enlighten me.
Thanks
 
What's the compiler error?
 
Cannot find symbol, constructor Awake.
 
I'm not a Java expert but try removing the "void" in the constructor.

public class Awake
{
public Awake(string time)
{
...
}
}

Make sure you have everything included to handle the System.out.println call too.
I could be wrong. :/

I really need to brush up on my Java.
 
Wow, don't I suck.

Yep, void is a return type, and making it void transforms the constructor into an ordinary method.

Thanks. Should've noticed that.
 
You don't suck, Flash. Overlooking things like that happen all the time.
I haven't programmed in Java in years and was just going by my C# experience. DOH !!
I guess for me, even a blind squirrel finds a nut once in awhile. :laugh:
 
Last edited:
You don't suck, Flash. Overlooking things like that happen all the time.
I haven't programmed in Java in years and was just going by my C# experience. DOH !!
I guess for me, even a blind squirrel finds a nut once in awhile. :laugh:

Kreij makes everyone feel like they suck, he solved a problem in a language that he didn't even know :P

Legend has it that Kreij developed the C language.

Historians maintain that the project was stolen from him.
 
Thanks for the laugh, 3870, but there are a lot of great coders here on TPU who make me look stupid in the languages I've not used in quite some time (like C++ and Java).

We all just try to help where we can. :toast:

BTW ... I was going to name it "K" before Dennis Ritchie stole the code and named it "C". :roll:
 
Back
Top