To get a Currency instance for the Indian rupee in Java, you can use the getInstance() method of the Currency class and pass a Locale object for India as an argument. Here's an example of how you could do this:
import java.util.Currency;
import java.util.Locale;
Currency currency = Currency.getInstance(new Locale("en", "IN"));
System.out.println("Currency code: " + currency.getCurrencyCode());
System.out.println("Currency symbol: " + currency.getSymbol());
This code will output the following:
Currency code: INR Currency symbol: ₹
You can also use the getInstance() method to get a Currency instance for a specific currency code. For example:
Currency currency = Currency.getInstance("INR");
System.out.println("Currency code: " + currency.getCurrencyCode());
System.out.println("Currency symbol: " + currency.getSymbol());
This code will produce the same output as the previous example.
Note that the Currency class is not thread-safe, so you should not use a single Currency instance concurrently from multiple threads. Instead, you should create a new instance for each thread, or use thread-local variables to store the Currency instances.