java.io library provides classes to handle input and output operations. It is mainly used to perform file operations, but also includes classes to handle other types of input and output streams. On the other hand, Math library provides mathematical functions and constants in java.
java.io library example:
import java.io.*;
public class FileReaderExample {
public static void main(String[] args) throws IOException {
FileReader in = null;
try { in = new FileReader("input.txt"); int c;
while ((c = in.read()) != -1) { System.out.print((char) c); } }finally { if (in != null) { in.close(); } } } }
This code reads characters from a file called input.txt and prints them on the console.
Math library example:
import java.lang.Math;
public class MathExample {
public static void main(String[] args) { double x = 345.88; double y = Math.log(x); System.out.println("Natural logarithm of " + x + " is " + y); } }
This code calculates the natural logarithm of a number using the log function provided by Math library.
Both examples belong to the standard java library, hence they don't require any additional package to be imported.
Java Math.log - 30 examples found. These are the top rated real world Java examples of java.io.Math.log extracted from open source projects. You can rate examples to help us improve the quality of examples.