我理解什么是java方法调用,并使用它练习了很多例子.
我想知道这个概念的实际情况或需要是什么.如果有人能够提供一个使用它的现实世界场景以及如果这个概念不存在会发生什么,那将是非常有帮助的?
我想连接到远程服务器以使用Log4J Socket Appender写入我的日志文件,我的log.properties文件如下所示
log4j.rootLogger=DEBUG, BLAH
# to connect to the remote server
log4j.appender.BLAH=org.apache.log4j.net.SocketAppender
# set set that layout to be SimpleLayout
log4j.appender.BLAH.layout=org.apache.log4j.SimpleLayout
#log4j.appender.BLAH.File= admin.log
log4j.appender.BLAH.Port= xx
log4j.appender.BLAH.RemoteHost= <remoteIp>
Run Code Online (Sandbox Code Playgroud)
我也尝试使用端口号22和8080连接本地主机
我在连接的某些地方犯了错误。我收到以下错误
log4j:ERROR Could not connect to remote log4j server at [localhost]. We will try again later.
Run Code Online (Sandbox Code Playgroud)
或给我任何建议在远程服务器计算机上写入日志文件。
HashMap<Integer,Integer> hashmapsample= new HashMap<Integer, Integer>();
Run Code Online (Sandbox Code Playgroud)
我可以有像这样的价值观
(1 , 7)
(2 , 4)
(4 , 5)
(3, 7)
Run Code Online (Sandbox Code Playgroud)
不会有任何重复的密钥.只能出现重复值
我想选择具有重复值的(Key,Value)对.
如果我将Duplicate(Key,Value)作为另一个Hashmap获得它会很棒.我该怎么做呢?
我期待输出
(1 , 7)
(3, 7)
Run Code Online (Sandbox Code Playgroud) 可能重复:
如何在Java中获取时区的当前日期和时间?
我已经开发了一个考勤系统,并在印度使用.我们的服务器在美国,因为他们使用的是PDT.我的代码反映了提前一小时的时间.
说它是IST上午9点----我得到的时间是IST上午10:00
除了检测一个小时之外,这将是一个临时解决方案.
请告诉我一些克服这种情况的方法
if(callingflag)
{
int calledUserTp = totalPointsByUserid(callinguserid,jokercard);
System.out.println("Total Points of the User Who has made a Call is ::"+calledUserTp);
HashMap<Integer,Integer> useridTotalRankMap = totalPointsforEveryUser(jokercard);
HashMap<Integer,Integer> useridTotalRankMapSorted = new HashMap<Integer, Integer>();
useridTotalRankMapSorted = (HashMap<Integer, Integer>) sortByComparator(useridTotalRankMap);
for(Map.Entry<Integer, Integer> entry :useridTotalRankMapSorted.entrySet())
{
System.out.println( entry.getKey() +"----"+entry.getValue());
if(entry.getKey() == callinguserid )
{
System.out.println( "GOOD CALL");
break;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能避免上面提到的for循环.useridTotalRankMapSorted是一个Map
我有这个名为useridTotalRankMap的hashmap,它将具有一些总点数的用户ID.
我想检查对应于calleruserid的值是否是该hashmap中的最小值,前提是没有关系.
说是
1:4
4:7
3:7
2:5
Run Code Online (Sandbox Code Playgroud)
和calleruserid = 1.如果key = 1的值(即4)是最小值,则打印"good call".
希望我现在很清楚.
我编码的方式有什么变化吗?