This project is designed to help developers understand the Java Stack Trace. By intentionally causing a division by zero error, we simulate a critical bug in a culinary calculation module. The goal is to identify the exception type and the exact line of code responsible for the crash by analyzing the console output.
- Task: Divide integer 10 by 0 in the
mainmethod. - Goal: Trigger an
ArithmeticExceptionand analyze the resulting Stack Trace. - Analysis: Identify the exception name and the line number in the source code.
- Java 8+
The program performs a direct division of two integers: 10 / 0. Since division by zero is mathematically undefined for integers in Java, the JVM immediately stops execution and prints a Stack Trace. This trace includes the exception class, the error message, and the sequence of method calls leading to the failure.
Exception in thread "main" java.lang.ArithmeticException: / by zero
at com.yurii.pavlenko.Solution.main(Solution.java:16)
Process finished with exit code 1
Project Structure:
src/com/yurii/pavlenko/
└── Solution.java
Code
package com.yurii.pavlenko;
public class Solution {
public static void main(String[] args) {
int totalIngredients = 10;
int ingredientsPerPortion = 0;
int portionsCount = totalIngredients / ingredientsPerPortion;
// This message will never be printed
System.out.println("Portions possible: " + portionsCount);
}
}This project is licensed under the MIT License.
Copyright (c) 2026 Yurii Pavlenko
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...
License: MIT