• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Very noobi question in Java

Joined
Jan 27, 2009
Messages
225 (0.07/day)
Likes
12
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
#1
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
 
Joined
Jan 27, 2009
Messages
225 (0.07/day)
Likes
12
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
#3
Cannot find symbol, constructor Awake.
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (3.46/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
#4
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.
 
Joined
Jan 27, 2009
Messages
225 (0.07/day)
Likes
12
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
#5
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.
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (3.46/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
#6
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:
Joined
Feb 26, 2008
Messages
4,870 (1.35/day)
Likes
681
Location
Joplin, Mo
System Name Ultrabeast GX2
Processor Intel Core 2 Duo E8500 @ 4.0GHZ 24/7
Motherboard Gigabit P35-DS3L
Cooling Rosewill RX24, Dual Slot Vid, Fan control
Memory 2x1gb 1066mhz@850MHZ DDR2
Video Card(s) 9800GX2 @ 690/1040
Storage 750/250/250/200 all WD 7200
Display(s) 24" DCLCD 2ms 1200p
Case Apevia
Audio Device(s) 7.1 Digital on-board, 5.1 digital hooked up
Power Supply 700W RAIDMAXXX SLI
Software winXP Pro
Benchmark Scores 17749 3DM06
#7
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.
 

Kreij

Senior Monkey Moderator
Joined
Feb 6, 2007
Messages
13,817 (3.46/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
#8
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: