I'm taking a Computer Science class that uses Java, and I've learned the same types of things plus a lot more in C++ at the same time, so I often see differences between them.
So anyways, I've noticed that the main method/function has to be in a class definition in Java, whereas in C++ it doesn't/isn't.
Did they make it this way because they are trying to keep Java Object-Oriented?
Java main method in class definition
Moderator: Coders of Rage
- Bullet Pulse
- Chaos Rift Cool Newbie
- Posts: 89
- Joined: Sun Feb 21, 2010 6:25 pm
- MrDeathNote
- ES Beta Backer
- Posts: 594
- Joined: Sun Oct 11, 2009 9:57 am
- Current Project: cocos2d-x project
- Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
- Programming Language of Choice: C/++
- Location: Belfast, Ireland
- Contact:
Re: Java main method in class definition
Both java and C++ are object orientated. C++ inherits the C language and C declares main in this fashion so thats probably why C++ declares main like that. I'm not sure why there's a difference it's highly possible that it was just a design desicion made by the creators of the languages.Bullet Pulse wrote:I'm taking a Computer Science class that uses Java, and I've learned the same types of things plus a lot more in C++ at the same time, so I often see differences between them.
So anyways, I've noticed that the main method/function has to be in a class definition in Java, whereas in C++ it doesn't/isn't.
Did they make it this way because they are trying to keep Java Object-Oriented?
http://www.youtube.com/user/MrDeathNote1988
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: Java main method in class definition
Typically everything in Java is seen as an object. It's the same way for C#.Bullet Pulse wrote:Did they make it this way because they are trying to keep Java Object-Oriented?