Java program to determine the class of a given IP address
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
In this program, we will read an IP address from the user and print the class of input IP address.
Program/Source Code:
The source code to print the class of the given IP address is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we imported the "java.util.Scanner" package to read input from the user. And, created a public class Main. It contain two static methods printIpClass() and main().
The printIpClass() method is used to extract octets from the input IP address and print the class of IP address.
The main() method is an entry point for the program. Here, we read an IP address in string format. Then we used printIpClass() method and printed the class of input IP address.