Create a Java program to demonstrate the use of an interface for custom weather information retrieval
interface WeatherService { String getWeatherInfo(String location); } public class Main { public static void main(String[] args) { WeatherService weatherService = new WeatherService() { @Override public String getWeatherInfo(String location) { // Implement weather information retrieval logic here (e.g., using a weather API) return "Weather in " + location + " : Sunny, 25°C"; } }; String location = "New York, USA"; // Get weather information String weatherInfo = weatherService.getWeatherInfo(location); System.out.println(weatherInfo); } }
Weather in New York, USA : Sunny, 25°C
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions