Put your text ad here
WestNIC provides reliable web hosting services
Free software downloads and drivers download resources
25% off cpanel web hosting and reseller hosting deals. Promo: codestyle25off
This FAQ is part of the Code Style Help and FAQ section. Join our premium content service for full access all FAQs, or choose the single FAQ by email option for premium answers.
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.
Actions: Follow-up, clarify or correct this answer. Submit a new question.
Hashtable and HashMap?
A: In Java 2 Hashtable fulfills 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.
… premium content omitted
Get full access to all FAQs, subscribe now for $40
What is the difference between Hashtable and HashMap?
Actions: Follow-up, clarify or correct this answer. Submit a new question.
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.
Actions: Follow-up, clarify or correct this answer. Submit a new question.
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.
Actions: Follow-up, clarify or correct this answer. Submit a new question.
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.
… premium content omitted
Get full access to all FAQs, subscribe now for $40
How do I insert slashes in a date?
Actions: Follow-up, clarify or correct this answer. Submit a new question.
Date object?
A: The recommended way to parse a String representation of a date to a Date object is to use the java.text.SimpleDateFormat class parse(String) method. In its simplest form, the class is instantiated with a String pattern argument that defines the general syntax of the date to be parsed. In the example below, the W3C date time format for year, month and day is represented by the pattern "yyyy-MM-dd" and is used to parse the date string "2008-09-20".
… premium content omitted
Get full access to all FAQs, subscribe now for $40
How can I convert a string into a Date object?
Actions: Follow-up, clarify or correct this answer. Submit a new question.
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.
… premium content omitted
Get full access to all FAQs, subscribe now for $40
How can I get the difference between two dates in days?
Actions: Follow-up, clarify or correct this answer. Submit a new question.
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.
… premium content omitted
Get full access to all FAQs, subscribe now for $40
Why isn't my custom Calendar class called?
Actions: Follow-up, clarify or correct this answer. Submit a new question.
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).
Actions: Follow-up, clarify or correct this answer. Submit a new question.
| Front-end FAQs | Back-end FAQs | Learning Java |
|---|---|---|
About us: site help, text ads, sponsored links and premium content FAQs.