File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Java Queries..Please help me... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Queries..Please help me..." Watch "Java Queries..Please help me..." New topic

Java Queries..Please help me...

Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 561

Hi Ranchers,
I have few java queries.

1> How to write a customized(user defined) Annotation.? Can you please give me an example for user defined Annotation class for the same ?

2> What is the difference between Static import and Enum constants in java wrt java 1.5 version.?

:roll: :roll: :roll: :roll:

Help provided will be highly appreciated.

Deepak Lal

When The Going Gets Tougher,The Tougher gets Going
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15092

About annotations: See Annotations in Sun's Java Tutorials.

Static import is not really meant for the same purpose as enums. Statically importing constants does not provide type safety like enums do. See Static import and Enums.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 561

Thanks for your valuable input,

Well,I went through the above website/links and i could not find an example for the USER DEFINED ANNOTATION.
Could you help me out with this.??
Please provide me with an example for User Defined Annotation ??
It will be highly appreciated if you could provide me with an example.??

Could you explain which is Type safe ?? Static Import or Enum type constants ??
what do you mean by Type-Safety ??

Help provided will be highly appreciated.

Deepak Lal
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46368
There is a nice chapter about annotations in Bruce Eckel's Thinking in Java 4th edition, not the edition which is available free of charge.

I am finding your question a bit difficult to understand; enums and static import have nothing to do with each other. There is something about the type-safe enumeration pattern in Joshua Bloch's Effective Java. You can find more about both books in our Bunkhouse.

We have probably gone beyond the beginner's level now: moving thread.
I agree. Here's the link:
subject: Java Queries..Please help me...
It's not a secret anymore!