Code5 Factorial of a given number(28/01/2025) #javaprogramming #java #inteviewcodingquestions

preview_player
Показать описание
Here are the important keywords and concepts in the provided Java code:

A way to organize classes into groups or folders in Java. It helps avoid name conflicts.

A way to bring in external libraries or classes to use them in your code. It saves you from writing code that's already been written.

3. **`public`**:
- Access modifier that makes the class or method accessible from any other class.

4. **`class`**:
- Defines a class in Java. Here, the class is named `Factorial`.

5. **`static`**:
- Indicates that the method can be called without creating an instance of the class. The `main` method and `fact` method are both `static`.

6. **`void`**:
- Specifies that the method does not return any value. The `main` method is of type `void`.

7. **`int`**:
- A data type representing a 32-bit integer.

8. **`if` / `else`**:
- Conditional statements. In this case, it's checking whether the input number is 0 and then deciding whether to calculate the factorial or not.

9. **`return`**:
- Used to return a value from a method. In the `fact` method, it returns the calculated factorial value.

10. **`new`**:

11. **`Scanner`**:

12. **`nextInt()`**:
- A method of `Scanner` class that reads the next integer input from the user.

- A method to print text to the console. It prints the result of the factorial calculation in this case.
Рекомендации по теме
welcome to shbcf.ru