Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的分配需要从 JOptionPane 提示消息“输入时间为 hh:mm:ss” 从该输入中,如何将值分配给我的变量 hh、mm 和 ss?
我尝试将它拆分为一个字符串,但它不会工作,因为它还没有被初始化。请帮忙?我对java真的很陌生。
String hh, mm, ss; String time = "12:01:54"; String[] tmp = time.split(":"); hh = tmp[0]; mm = tmp[1]; ss = tmp[2]; System.out.println("Hours: " + hh + " Minutes: " + mm + " Seconds: " + ss);
假设您的输入是一个字符串,并且您希望将您的值存储为字符串。