• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

code problem

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello, everyone I have a doubt ?



[HENRY: Added Code Tags]
[ August 15, 2008: Message edited by: Henry Wong ]
 
nitin ratra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is wrong in this code ?
Actually I thinking I have done some errors in accessing the static method inside the main method. SO people how do I acess the non static method inside main method?

Actually I want to access the Iday
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a few things wrong.

Firstly, you can't access the non static methods directly from main. Instead create your Independence instance within the main method (check the variable assignment in your constructor its the wrong way round) and call its Iday method.
[ August 15, 2008: Message edited by: Richard Bradford ]
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have already told you, please Use Code Tags and tell us in the subject line what the topic is about.
 
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nitin,

I think what Richard mentioned, is that the first problem appears to lie with your constructor.

you have



when it should be:



Also I guess by your Class name, you are Indian? If so, may I wish you a very Happy Idependence day! Jai Hind!
 
nitin ratra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks friend for taking keen intrest in my problem and thanks for wishiing mee independence day , yes I am an Indian
 
nitin ratra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It must be a very simple question , but I want to ask it if you pepole can explain mee. I can provide a constructor to my class but actually I don't know what a constructor does?
I have read sun tutorial,but actually I can't get the real picture fo it .
Please if I can get something about constructor. I know it is a foolish type question but please if I get some knoledge of it.
regards
Nitin
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


One way of looking constructor is to consider it as a suitable place where you can write code which needs to be executed whenever an object of that class is intantiated. The code should usually be doing the initialization stuff for that object.
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Satya Maheshwari:


One way of looking constructor is to consider it as a suitable place where you can write code which needs to be executed whenever an object of that class is intantiated. The code should usually be doing the initialization stuff for that object.

Be bold, Maheshwari!

The constructor is where you initialise the object. Not "should" or "usually." For the beginner, let's think of that as "always." [There are other ways to initialise objects, like factory methods, but let's look on them as more advanced than we need here.]

Every field has a default value when it is declared, but that is usually not suitable for real-life use, so you initialise them to "real" values in the constructor.

Nitin: who is teaching you programming? Have you got a course of any sort?
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Be bold, Maheshwari!


With experts all around the ranch, one never knows when one has put himself in a spot.
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nitin! your code should look like this

[ August 15, 2008: Message edited by: ARIJIT DARIPA ]
 
nitin ratra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all members .
 
Campbell Ritchie
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.

Please remember about titles for threads in future.
reply
    Bookmark Topic Watch Topic
  • New Topic