我有一个ping.js应用程序ping一个网址,然后如果它得到一个错误代码,发送一条消息给Slack.它工作正常两天,但它只是停止工作.我正在使用Screen来保持运行,但它似乎仍然停止.任何帮助将不胜感激.
代码如下:
var request = require("request")
var Hapi = require('hapi');
var Slack = require('slack-node');
var h = 0;
var s = 0;
var e = 0;
function onlineBooking(){
request({
url: "http://example.com",
json: true
}, function (error, response, body) {
if (!error && response.statusCode === 200) {
// 'if/else' checks that it receives an up respsose four times in a row
// the variable e is increased by .25 for every 200(ok response) until e reaches 1
// it will then …Run Code Online (Sandbox Code Playgroud) public class dereks {
public static void main (String [] args){
int array [] = {1,2,3,5,6,7};
int sum =0;
for(int counter=0; counter<=array.length; counter++){
sum+=array[counter];
}
System.out.println(sum);
}
}
Run Code Online (Sandbox Code Playgroud)
谁能告诉我这有什么不对?我无法理解为什么我收到错误消息"线程中的异常"主"java.lang.ArrayIndexOutOfBoundsException:5 at dereks.main(dereks.java:7)".