+ 7

Error

My code is showing access error..... Please tell me how to solve this... https://code.sololearn.com/c5y5OFI5L5Qt/?ref=app

20th Aug 2019, 11:35 AM
Shadow Ninja[#Inactive]
Shadow Ninja[#Inactive] - avatar
1 Resposta
+ 2
import java.net.*; public class Program { public static void main(String[] args) throws UnknownHostException { System.out.println(InetAddress.getLocalHost()); } } get localHost() is a static method which returns an object from type InetAddress. InetAddress IP = InetAddress.getLocalHost(); should also work. It can throw an exception which you need to handle, otherwise you get an error message.
20th Aug 2019, 1:14 PM
Denise Roßberg
Denise Roßberg - avatar