aspose file tools
The moose likes Beginning Java and the fly likes classes  in java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "classes  in java" Watch "classes  in java" New topic
Author

classes in java

irrfan jamadar
Greenhorn

Joined: May 09, 2012
Posts: 9

why to write everything in class.Can anyone tell me with real life example.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 3865
    
    1

Welcome to the Ranch!

Well, the answer's simple. Java is an object-oriented language, and in a class is the only place it allows you to write code. So you don't need an example to demonstrate that.

If you mean, "why is it designed that way", that's a huge question that we're not going to be able to effectively answer here. I'd suggest reading a tutorial on object-oriented programming to get an idea of how it works.

If you've got some more specific questions we might be able to help you.
irrfan jamadar
Greenhorn

Joined: May 09, 2012
Posts: 9

Thanks for your reply.But Can I know which tutorial or book you suggest me for understanding this concept like why everything should go into class.what will happen if we will not use class.This question was asked in interview.
Palak Mathur
Ranch Hand

Joined: Jan 29, 2007
Posts: 303

irrfan jamadar wrote:Thanks for your reply.But Can I know which tutorial or book you suggest me for understanding this concept like why everything should go into class.what will happen if we will not use class.This question was asked in interview.


Hi Irrfan,

In Java everything goes inside a class because it is how it is meant to be so that OOO features can be utilized fruitfully. You will need to go through the OO Concepts. I would recommend you to buy t Head First Object-Oriented Analysis & Design and go through it and all your basics regarding this issue will get resolved. IF you still face issues then come back here and ask your specific questions.


Palak Mathur | My Blog | TechJaunt | What is JavaRanch? | List of All FAQs
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: classes in java