aspose file tools*
The moose likes Beginning Java and the fly likes  a class can only have static fields? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark " a class can only have static fields?" Watch " a class can only have static fields?" New topic
Author

a class can only have static fields?

abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
a class can only have static fields ??? if yes then please tell me why is it so ???

like this one

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/Thread.html
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11231
    
  16

I have no idea where you got that idea from, but it is 100% not true. If it could only have "static" fields, why would you need to call them "static" - they'd just be fields.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
fred rosenberger wrote:I have no idea where you got that idea from, but it is 100% not true. If it could only have "static" fields, why would you need to call them "static" - they'd just be fields.



actually i was working on Thread class .. i noticed that .. on clicking at " PREV CLASS " on that page (link given above) it appears that many classes provided by java system have static fields .. so i asked
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

Same logic: I saw a black dog the other day, so all dogs must be black.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
Bear Bibeault wrote:Same logic: I saw a black dog the other day, so all dogs must be black.


i think my question was a very stupid one ................ sorry
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

No, just pointing out the flaw in your logic. One or two examples is not enough to draw such conclusions on.
abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
Bear Bibeault wrote:No, just pointing out the flaw in your logic. One or two examples is not enough to draw such conclusions on.




Oh I think I misunderstood, thanks for clarifying this for me
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11231
    
  16

you would be amazed at how many times everyone here at some point drew a conclusion, only a day/week/month later go "What the heck was I THINKING?". In fact, that is why my forehead is so flat - i keep smacking it each time I realize something that should have been obvious.

Don't worry about asking questions - that's what this site is all about.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363
    
  23
It's a language error. It should read "Can a class have only static fields?" to which the answer is yes. And I don't think people ought to have made fun of you about that mistake.

Go into your Java™ installation folder and find a file called src.zip. Unzip that, and find the "java" folder and inside that the "lang" folder and inside that the "Math.java" file. Explore that file and you can see how it is done.

You can call that a utility class.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61010
    
  65

fred rosenberger wrote:In fact, that is why my forehead is so flat - i keep smacking it each time I realize something that should have been obvious.

For me, it's the side of my head -- from smacking it against the wall.

Seriously, no one is making fun of anyone. Learning from mistakes is sometimes the best learning.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363
    
  23
My apologies then. I can get a bit sensitive about that sort of thing sometimes.
khekhone yvan
Ranch Hand

Joined: May 08, 2011
Posts: 79
maybe
he wnat to say
a static class has to static fields
abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
khekhone yvan wrote:maybe
he wnat to say
a static class has to static fields


i think i would like to say ........."please give me name of a class having non- static fields in java system , if any ".
abhay jain
Ranch Hand

Joined: Jun 03, 2011
Posts: 130
Campbell Ritchie wrote:Go into your Java™ installation folder and find a file called src.zip. Unzip that, and find the "java" folder and inside that the "lang" folder and inside that the "Math.java" file. Explore that file and you can see how it is done.
.


right now following your instructions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a class can only have static fields?