Results 1 to 7 of 7

Thread: java basics

  1. #1
    rachushetty is offline Member
    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0

    Default java basics

    Why should we create an object? what is a need of it? Apart from access members of a class i want what is a need of object what does it contain?? In normal class to access any member of that class we create object where as for static class we access its members using class name. what is a difference between them. iknow we can create an object for static class but no use of it. thanks in advance.

  2. #2
    lannie1980 is offline Member
    Join Date
    Mar 2012
    Posts
    88
    Rep Power
    0

    Default Re: java basics

    Hi, I'm sorry to all the others that I replied 1st....

    Objects are required to interact in a program with other objects or else the program does f**k all. You should read the very 1st few chapters of your java course to realize this. Static classes are available for all to use within the defined package. You deffo need to re-read your course materials m8 before posting nonsense like this - Please re-read your intro course books then come back to us with questions about static class objects and the likes.
    Moderator - change as necessary.

  3. #3
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,446
    Rep Power
    18

    Default Re: java basics

    Put another way, Java is an Object Oriented language.
    It's written based on that concept.

    If you don't want to use objects then pick a non-OO language as it will probably do a better job.

    Now, as for why you should be using OO instead of, say, straight procedural, then there are plenty of articles out there that can explain this in details. It essentially boils down to it being easier to maintain and write code that is structured such that its data and methods sit together in nice little units (classes/objects) and that those units can be extended such that you don't have to copy code between these nice little units (inheritance).

    Writing straight into classes using static methods and data can give you the first bit, but not the second.
    Please do not ask for code as refusal often offends.

  4. #4
    rachushetty is offline Member
    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0

    Default Re: java basics

    Quote Originally Posted by lannie1980 View Post
    Hi, I'm sorry to all the others that I replied 1st....

    Objects are required to interact in a program with other objects or else the program does f**k all. You should read the very 1st few chapters of your java course to realize this. Static classes are available for all to use within the defined package. You deffo need to re-read your course materials m8 before posting nonsense like this - Please re-read your intro course books then come back to us with questions about static class objects and the likes.
    Moderator - change as necessary.
    thanks for your answer. bt please mind your words. think before saying something . this is ofcourse not a non sense. you are giving me the defination that you have read from some text book. just come out of that box,think out of box..
    sorry to say this..

  5. #5
    rachushetty is offline Member
    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0

    Default Re: java basics

    thanks a lott for ur answer.but i have one more doubt, instead of creating object cant we use class name directly to access its members.(classname.member)
    and what object contains?
    is object a reference variable?

  6. #6
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,446
    Rep Power
    18

    Default Re: java basics

    Objects contain their attributes.
    Some of those attributes may be references to other objects on the heap.

    You can use ClassName.member, if 'member' is static. Which, of course, means you can only have one 'ClassName.member' in your application.
    Please do not ask for code as refusal often offends.

  7. #7
    lannie1980 is offline Member
    Join Date
    Mar 2012
    Posts
    88
    Rep Power
    0

    Default Re: java basics

    Hi,

    Yes I was a bit harsh there in hindsight and I apologise for that. No questions asked on these forums are nonsense of course - how else do you learn? Tolls answer is much more constructive and informative. Creating objects and using them and making them interact is the fundamental principle of Object Oriented Programming.

    Thanks

Similar Threads

  1. Replies: 1
    Last Post: 06-29-2012, 12:32 AM
  2. basics of java
    By kmd prasadNaidu in forum New To Java
    Replies: 5
    Last Post: 12-27-2011, 03:42 PM
  3. Anyone willing to help me with Java basics?
    By Rocketz in forum New To Java
    Replies: 7
    Last Post: 02-23-2011, 04:30 AM
  4. What loop? Java Networking Basics
    By JonnySnip3r in forum Networking
    Replies: 0
    Last Post: 01-28-2010, 08:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •