- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Karthikeya Boyini has Published 2383 Articles
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
karthikeya Boyini
1K+ Views
To calculate distance light travels, we need to follow the basic formulae to calculate distance.Distance = Speed x TimeHere, the following are the parameters −speed = 186000; days = 365; seconds = days * 24 * 60 * 60;Above, we calculated the time in seconds for an year −days = ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
karthikeya Boyini
227 Views
The mail() function allows in sending emails directly from a script.Syntaxmail(to, sub, msg, headers, parameters);Parametersto − The receiver / receivers of the emailsub − The subject of the email.msg − The message to be sent.headers − The additional headers, such as From, Cc, and Bcc.parameters − The additional parameter to ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
karthikeya Boyini
210 Views
Use the negate() method to negate a BigDecimal value in Java. The method returns a BigDecimal whose value is (-this), and whose scale is this.scale().The following is an example −Example Live Demoimport java.math.BigDecimal; public class Demo { public static void main(String[] argv) throws Exception { ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
karthikeya Boyini
236 Views
The “m” format is to format minutes i.e. 1, 2, 3, 4, etc. Here, we will use the following.SimpleDateFormat("m");Let us see an example −// displaying minutes in m format SimpleDateFormat simpleformat = new SimpleDateFormat("m"); String strMinute = simpleformat.format(new Date()); System.out.println("Minutes in m format = "+strMinute);Above, we have used the SimpleDateFormat ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
karthikeya Boyini
2K+ Views
The truncate BigDecimal value in Java, try the following code.Here, we have taken two BigDecimla values and set the round mode for truncating the decimal values −Example Live Demoimport java.math.BigDecimal; public class Demo { public static void main(String[] argv) throws Exception { ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
karthikeya Boyini
1K+ Views
The java.math.BigDecimal class provides operations for arithmetic, scale manipulation, rounding, comparison, hashing, and format conversion.Two types of operations are provided for manipulating the scale of a BigDecimal −scaling/rounding operationsdecimal point motion operationsThe following are some of the constructors of the BigDecimal values −Sr.No.Constructor & Description1BigDecimal(BigInteger val)This constructor is used to ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
karthikeya Boyini
60 Views
Firstly, let us declare and initialize three long values.long val1 = 88799; long val2 = 98567; long val3 = 98768;Now, find the minimum of three long values using the following condition −// checking for maximum if (val2 < val1) { val1 = val2; } if (val3 < ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
karthikeya Boyini
82 Views
DecimalFormat is a concrete subclass of NumberFormat that formats decimal numbers.Let us set DecimalFormat(abc#) first −Format f = new DecimalFormat("'abc'#");Now, we will format a number and display the result in a string using the format() method −String res = f.format(-3968.7878);Since, we have used both Format and DecimalFormat class in Java, ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
karthikeya Boyini
137 Views
The toString() method gives string representation to a Long. Let’s say we have the following Long object −Long longObj = new Long(70); System.out.println("Long: " + longObj);To convert it to String, the toString() method is used −String myStr = longObj.toString();The following is the complete example −Example Live Demopublic class Demo { ... Read More
![karthikeya Boyini](https://www.tutorialspoint.com/assets/profiles/13518/profile/60_31598-1537784993.jpg)
karthikeya Boyini
133 Views
Firstly, set the double values −double d1 = 1.39876; double d2 = 2.39876; double d3 = 0.66920;Now, format the double values with new DecimalFormat("0.#####E0") −System.out.println(new DecimalFormat("0.#####E0").format(d1)); System.out.println(new DecimalFormat("0.#####E0").format(d2)); System.out.println(new DecimalFormat("0.#####E0").format(d3));The following is an example −Example Live Demoimport java.text.DecimalFormat; public class Demo { public static void main(String[] argv) throws ... Read More