Place your text ad here.
World class data recovery software and renowned raid recovery services
WestNIC provides reliable web hosting services
Free software downloads and drivers download resources
Ahosting.biz reseller hosting, managed dedicated server with 24/7 support
This FAQ is part of the Code Style Help and FAQ section. Use the help request form below if your question is not answered here, but make sure you are asking the right question first.
Hashtable put() method?
Hashtable and HashMap?
Map?
Vector a legacy class?
Hashtable put() method?
A: You should download the Java API documentation, which details all standard classes and their method parameters. The first parameter in a Hashtable's put method is the key by which the value in the second argument will be stored.
To retrieve the stored value, use the get(Object) method, where the object parameter is a reference to the key.
Hashtable and HashMap?
A: In Java 2 Hashtable fulfils the Map interface like HashMap. The main difference between Hashtable and HashMap is that HashMap is not synchronized and allows a null key to be used and null values to be stored.
More details available to subscribers:
What is the difference between Hashtable and HashMap?
Map?
A: To get the keys in a map rather than the values, use the keySet() method, which returns a java.util.Set object that contains all the keys. You can then get an Iterator from the key set, or process the keys using other Set methods.
Vector a legacy class?
A: Vector is a legacy class that was adapted in Java Software Development Kit version 1.2 to integrate it with the more contemporary collections framework. Vector now implements the Collection interface.
A: To format Date types in Java, you should use a java.text.SimpleDateFormat. This class takes a time pattern string and applies it to the given date like a template. To create a date with slashes, you might use the pattern "dd/MM/YYYY" for instance.
More details available to subscribers:
How do I insert slashes in a date?
A: To compare dates by day, deduct the millisecond time of the earlier date from the later one and divide the result by the number of milliseconds in a day. This method checks the dates are not the same and uses the after(Date) method to check the deduction is the right way round. For finer comparisons by hour or minute, it is important to check any possible timezone offset too.
More details available to subscribers:
How can I get the difference between two dates in days?
Calendar class called?
A: If you have a broad import statement like import java.util.*;, the Java Virtual Machine will adopt the standard distribution version of any named class, such as java.util.Calendar. You should limit the scope of your import statements and use the fully qualified name of the custom Calendar class.
More details available to subscribers:
Why isn't my custom Calendar class called?
Calendar.getInstance()?
A: The Calendar class is abstract and instances must be obtained from the static getInstance() method so that they are created with an appropriate locale. Calendars must be created with a specific Locale reference to take account of regional time zones and any seasonal daylight saving changes when getting dates, including AM or PM values and time relative to Greenwich Meantime (GMT).
| Front-end FAQs | Back-end FAQs | Learning Java |
|---|---|---|
See site help for questions about this site, our text ads and sponsored links services.