File file = new File("sample.txt"); try (BufferedReader br = new BufferedReader(new FileReader(file))) { String line; while ((line = br.readLine()) != null) { System.out.println(line); } } catch (IOException e) { e.printStackTrace(); }
double num1 = 4.5; double num2 = 2; double result = Math.pow(num1, num2); // 4.5^2 = 20.25 System.out.println(result);
Random random = new Random(); int num = random.nextInt(10); // Generates a random number between 0 and 9 System.out.println(num);All of these libraries are part of the standard Java library and do not require any additional packages or installations.