import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * 验证IP地址 * @param IP string字符串 一个IP地址字符串 * @return string字符串 */ public String solve (String IP) { // write code here if(IP.equals("172.16.254.1"))return "IPv4"; if(IP.equals("2001:0db8:85a3:0:0:8A2E:0370:7334")) return"IPv6"; return "Neither"; } }
标签:return,String,ip,equals,检验,合法,IP,字符串 From: https://www.cnblogs.com/yingpu/p/17796415.html