เป็นฟังก์ชันในตัวใน Java ที่ใช้ในการคูณค่าสองค่าที่ส่งผ่านเป็นอาร์กิวเมนต์ไปยังฟังก์ชัน นี่คือตัวอย่าง −
ตัวอย่าง
import java.lang.Math;
public class Demo{
public static void main(String args[]){
int a = 12, b = 34;
System.out.printf("Product is : ");
System.out.println(Math.multiplyExact(a, b));
long c = 78, d = 93;
System.out.printf("Product is : ");
System.out.println(Math.multiplyExact(c, d));
}
} ผลลัพธ์
Product is : 408 Product is : 7254
คลาสชื่อ Demo มีฟังก์ชันหลัก ในที่นี้ มีการกำหนดตัวแปรสองตัว และผลิตภัณฑ์ของพวกมันคำนวณโดยใช้ฟังก์ชัน 'multiplyExact' ตอนนี้มีการกำหนดจำนวนเต็มแบบยาวสองจำนวนแล้ว และอีกครั้ง ผลิตภัณฑ์ของพวกมันจะถูกคำนวณโดยใช้ฟังก์ชัน 'multiplyExact' ถัดไปจะพิมพ์ลงบนคอนโซล