如何迭代Set/ HashSet没有以下内容?
Iterator iter = set.iterator();
while (iter.hasNext()) {
System.out.println(iter.next());
}
Run Code Online (Sandbox Code Playgroud) public final static HashMap<String, Integer> party = new HashMap<String, Integer>();
party.put("Jan",1);
party.put("John",1);
party.put("Brian",1);
party.put("Dave",1);
party.put("David",2);
Run Code Online (Sandbox Code Playgroud)
如何返回多少人的价值1
有没有办法使用Bash/Shell启用和禁用Crontab任务?
因此,当用户启动Server 1时,它将启用Server 1 Crontab行,依此类推.当用户停止服务器1时,服务器1 Crontab行被禁用(#).这可能吗?怎么样?
提前致谢
*/1 * * * * Server 1 check
*/1 * * * * Server 2 check
*/1 * * * * Server 3 check
Run Code Online (Sandbox Code Playgroud) OPTIONS="java -Xms1024M -Xmx1024M -jar craftbukkit.jar"
PROCESS=server01
screen -dmS $PROCESS $OPTIONS nogui # Starting the application
screen -x $PROCESS -X stuff `printf "stop\r"` # Closing the application
screen -x $PROCESS # Attaching to the terminal of the application
Run Code Online (Sandbox Code Playgroud)
应用程序在开始时工作正常,但是我遇到问题stuff 'printf "stop/r"'
当我刚启动时似乎没有工作,等待一段时间然后尝试使用上面的命令停止它.但奇怪的是,如果我这样做screen -x $PROCESS并且分离(ctrl-A & ctrl-D)然后我使用Stop命令它确实有效.那么,有没有办法解决,以stuff printf不screen -x $PROCESS?
如何启动可作为Root-User和Default-User访问的Screen?因为现在当我使用以下命令启动Screen as Default-User时:
screen -dmS test java $JAR nogui
Run Code Online (Sandbox Code Playgroud)
执行命令并登录Root-User并尝试使用后
screen -x test
Run Code Online (Sandbox Code Playgroud)
它会说,它不存在,因为屏幕是用户绑定的,AFAIK.
那么有一种方法可以将屏幕共享给所有用户吗?所以我可以通过任何用户的屏幕名称附加屏幕.
我有一个Polygon:

我想检查一个实体的位置是否在此内Polygon.
例如x:5和y:5,如何检查此坐标是否在此Polygon(Java)中?
Map<String, Data> map = new HashMap<String,Data>();
map.put("jan", new Data("RED","M4A1",5,0,0));
Run Code Online (Sandbox Code Playgroud)
如何更改数据对象的值RED?,而不是使用键从地图中获取所有信息并将其重新放入,如下所示:
map.put("jan" new Data("Blue",
map.get("jan").Brand,
map.get("jan").Storage,
map.get("jan").Sold,
map.get("jan").Bought));
Run Code Online (Sandbox Code Playgroud)
那么如何更改数据对象的1值而不是重做它们呢?
我想将HashSet存储到服务器目录中.但我现在只能将它存储在.bin文件中.但是如何将HashSet中的所有Key打印到.txt文件?
static Set<String> MapLocation = new HashSet<String>();
try {
SLAPI.save(MapLocation, "MapLocation.bin");
} catch (Exception ex) {
}
public static void save(Object obj, String path) throws Exception {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(
path));
oos.writeObject(obj);
oos.flush();
oos.close();
}
Run Code Online (Sandbox Code Playgroud) String weapon = "pistol . <1/10>";
Result:
int clip = 1;
int ammo = 1;
Run Code Online (Sandbox Code Playgroud)
string =(WEAPON)的格式.<(CLIP)/(AMMO)>
我需要Clip和Ammo值.
那么我如何才能提取String的这两个值.我可以用"/"拆分它仍然会面对:"枪<1"和"10>"
提前感谢
我想在1个键中存储3个值.Hashmap只能容纳1个键,1个值,因此无法使用.那么我还有什么方法可以从价值A/B/C的一把钥匙中获得.
键:字符串
值:String/String/int