• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

code problem

 
nitin ratra
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Richard Bradford
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • 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 ]
 
Campbell Ritchie
Sheriff
Posts: 51348
87
  • Mark post as helpful
  • send pies
  • 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.
 
Stephen Davies
Ranch Hand
Posts: 352
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 51348
87
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Arijit Daripa
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Thanks to all members .
 
Campbell Ritchie
Sheriff
Posts: 51348
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.

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