int length = 0;
for(int idx = 0; idx < a.length; i++) {
     length++;
}
System.out.println("length is : " + length);
By Slacki, 2015-07-22 14:25:02
private static int alphabetToNumber(String letter) {
    String s = letter.toLowerCase();
    if (s.equals("a")) {
        return 1;
    } else if (s.equals("b")) {
        return 2;
    } else if (s.equals("c")) {
        return 3;
    } else if (s.equals("d")) {
        return 4;
    } else if (s.equals("e")) {
        return 5;
    } else if (s.equals("f")) {
        return 6;
    } else if (s.equals("g")) {
        return 7;
    } else if (s.equals("h")) {
        return 8;
    } else if (s.equals("i")) {
        return 9;
    } else if (s.equals("j")) {
        return 10;
    } else if (s.equals("k")) {
        return 11;
    } else if (s.equals("l")) {
        return 12;
    } else if (s.equals("m")) {
        return 13;
    } else if (s.equals("n")) {
        return 14;
    } else if (s.equals("o")) {
        return 15;
    } else if (s.equals("p")) {
        return 16;
    } else if (s.equals("q")) {
        return 17;
    } else if (s.equals("r")) {
        return 18;
    } else if (s.equals("s")) {
        return 19;
    } else if (s.equals("t")) {
        return 20;
    } else if (s.equals("u")) {
        return 21;
    } else if (s.equals("v")) {
        return 22;
    } else if (s.equals("w")) {
        return 23;
    } else if (s.equals("x")) {
        return 24;
    } else if (s.equals("y")) {
        return 25;
    } else if (s.equals("z")) {
        return 26;
    } else {
        return 0;
    }
}
By Anonymous, 2015-07-22 14:54:18
public boolean logout(String token)
{
    LogedUser user = logedUsers.remove(token);
    return (user != null) ? true : false;
}
By Slacki, 2015-11-17 17:58:53
dotychczasowyPostep += predkosc * 1;
By tb, 2017-03-29 22:35:52
private boolean isToRemove(byte b) {
    byte[] toRemoveB = { -106 };
    for(byte c : toRemoveB) {
        if(b == c) {
            return true;
        }
    }
    return false;
}

it goes without saying...

By Unknown, 2017-09-26 17:45:20
if (baza[mCurrentIndex] == Boolean.TRUE) {
            if (mCurrentIndex != baza.length-1) {
                up();
                nextQuestion();
            }

            if (mCurrentIndex == baza.length) {
                WypiszWynik();
            }

        }

so you have an array of booleans and you're comparing it to Boolean.TRUE why

By pain, 2017-10-31 21:58:54
@RequestMapping(value = "user/getOnlineApplicationsList", produces = "XML/Text; charset=utf-8", method = RequestMethod.POST)
	public @ResponseBody String getOnlineApplicationsList(HttpSession session, HttpServletRequest request,
			@RequestParam("status") int status, @RequestParam("fullname") String fullname,
			@RequestParam("privateNumber") String privateNumber, @RequestParam("phoneNumber") String phoneNumber,
			@RequestParam("applicationIdFrom") String applicationIdFrom,
			@RequestParam("applicationIdTo") String applicationIdTo,
			// @RequestParam("dateFrom") String timeFrom,
			// @RequestParam("dateTo") String timeTo,
			@RequestParam("order") int order, @RequestParam("companyId") int companyId) {
		try {
			TimeFunctions tf = new TimeFunctions();
			StringBuilder ret = new StringBuilder();
			List<OnlineApplication> onlineAppList = new ArrayList<OnlineApplication>();
			List<OnlineApplicationForConsumerLoan> onlineAppListCL = new ArrayList<OnlineApplicationForConsumerLoan>();

			if (companyId == 3) {
				onlineAppList = onlineAppService.getOnlineApps(fullname, privateNumber,
						tf.dateStrToMilliseconds("11-11-1111"), tf.dateStrToMilliseconds("11-11-9999"), 0, 250, order,
						status, phoneNumber, applicationIdFrom, applicationIdTo);
			}
			else if (companyId == 2) {
				onlineAppListCL = onlineAppService.getConsumerOnlineApps(fullname, privateNumber,
						tf.dateStrToMilliseconds("11-11-1111"), tf.dateStrToMilliseconds("11-11-9999"), 0, 250, order,
						status, phoneNumber, applicationIdFrom, applicationIdTo);
			}
		
			else {
				onlineAppList = onlineAppService.getOnlineApps(fullname, privateNumber,
						tf.dateStrToMilliseconds("11-11-1111"), tf.dateStrToMilliseconds("11-11-9999"), 0, 250, order,
						status, phoneNumber, applicationIdFrom, applicationIdTo);
				onlineAppListCL = onlineAppService.getConsumerOnlineApps(fullname, privateNumber,
						tf.dateStrToMilliseconds("11-11-1111"), tf.dateStrToMilliseconds("11-11-9999"), 0, 250, order,
						status, phoneNumber, applicationIdFrom, applicationIdTo);
			}
			for (OnlineApplication onlineApp : onlineAppList) {
				if (onlineApp.getStatus() == 0) {
					ret.append("<br>"
							+ "<table style=\"width:100%; height: 180px; border: 1px solid black; text-align:center; border-collapse: collapse; spacing: 5px;\">"
							+ "<tr style=\"background-color:#85C1E9; height: 20px; font-weight: bold;\">"
							+ "<td>ID</td>" + "<td>თანხა</td>" + "<td>პერიოდი</td>" + "<td>სახელი გვარი</td>"
							+ "<td>დაბ.თარიღი</td>" + "<td>პირადი ნომ.</td>" + "<td>მობილური</td>"
							+ "<td>სამუშაო სფერო</td>" + "<td>კომპანია</td>" + "<td>პოზიცია</td>" + "<td>ხელფასი</td>"
							+ "<td>სტატუსი</td>" + "</tr>" + "<tr>" + "<td>" + onlineApp.getOnlineAppId() + "</td>"
							+ "<td>" + Math.round(onlineApp.getAmount().doubleValue() * 100.0) / 100.0 + "</td>"
							+ "<td>" + onlineApp.getPeriod() + "</td>" + "<td>" + onlineApp.getFullname() + "</td>"
							+ "<td>" + onlineApp.getBirthdate() + "</td>" + "<td>" + onlineApp.getPersonalNumber()
							+ "</td>" + "<td>" + onlineApp.getMobilephone() + "</td>" + "<td>"
							+ onlineApp.getWorkField() + "</td>" + "<td>" + onlineApp.getCompanyName() + "</td>"
							+ "<td>" + onlineApp.getPosition() + "</td>" + "<td>" + onlineApp.getSalary() + "</td>"
							+ "<td>" + getNameForStatus(onlineApp.getStatus()) + "</td>" + "</tr>"
							+ "<tr style=\"background-color:#85C1E9; height: 20px; font-weight: bold;\">"
							+ "<td>მუშ.ხან.</td>" + "<td>დამ.შემოსავალი</td>" + "<td>თვ.გადასახდელი</td>"
							+ "<td>ოჯახ.მდგომ.</td>" + "<td>შვილები</td>" + "<td>დასაქ.ოჯახ.წევრები</td>"
							+ "<td>საერთო შემოსავალი</td>" + "<td>თარიღი</td>" +  "<td>ინკასო</td>" +
							"<td>დადასტურება</td>"+ "<td>უარყოფა</td>" + "<td>წაშლა</td>" + "</tr>" + "<tr>" + "<td>"
							+ onlineApp.getWorkTime() + "</td>" + "<td>" + onlineApp.getAdditionalIncome() + "</td>"
							+ "<td>" + onlineApp.getLoanFreqAmount() + "</td>" + "<td>" + onlineApp.getMaritalStatus()
							+ "</td>" + "<td>" + onlineApp.getChildren() + "</td>" + "<td>"
							+ onlineApp.getWorkingRelatives() + "</td>" + "<td>" + onlineApp.getTotalIncome() + "</td>"
							+ "<td>" + tf.millisecondsToDateStr(onlineApp.getAdditionTime()) + "</td>"
							+ "<td>"+(onlineApp.isIncaso() ? "ინკასო":"არ ადევს")+"</td>" + "<td bgcolor=\"lightgreen\" onclick=\"approveApplication(" + onlineApp.getOnlineAppId()
							+ "," + onlineApp.getCompany() + ")\"><img height=\"20px\" width=\"20px\" src=\""
							+ request.getContextPath() + "/resources/images/accept.png\"></td>"
							+ "<td bgcolor=\"LightCoral\" onclick=\"rejectApplication(" + onlineApp.getOnlineAppId()
							+ "," + onlineApp.getCompany() + ")\"><img height=\"20px\" width=\"20px\" src=\""
							+ request.getContextPath() + "/resources/images/reject.png\"></td>"
							+ "<td bgcolor=\"silver\" onclick=\"deleteApplication(" + onlineApp.getOnlineAppId() + ","
							+ onlineApp.getCompany() + ")\"><img height=\"20px\" width=\"20px\" src=\""
							+ request.getContextPath() + "/resources/images/delete.png\"></td>" + "</tr>" + ""
							+ "<tr><td colspan=\"3\">" + onlineApp.getLoanPurpose() + "</td><td colspan=\"5\">" + onlineApp.getBranch() + "</td></tr></table>" + "<br>");
				} else if (onlineApp.getStatus() == 1) {
					ret.append("<br>"
							+ "<table style=\"width:100%; height: 180px; border: 1px solid black; text-align:center; border-collapse: collapse; spacing: 5px;\">"
							+ "<tr style=\"background-color:#85C1E9; height: 20px; font-weight: bold;\">"
							+ "<td>ID</td>" + "<td>თანხა</td>" + "<td>პერიოდი</td>" + "<td>სახელი გვარი</td>"
							+ "<td>დაბ.თარიღი</td>" + "<td>პირადი ნომ.</td>" + "<td>მობილური</td>"
							+ "<td>სამუშაო სფერო</td>" + "<td>კომპანია</td>" + "<td>პოზიცია</td>" + "<td>ხელფასი</td>"
							+ "<td>სტატუსი</td>" + "</tr>" + "<tr>" + "<td>" + onlineApp.getOnlineAppId() + "</td>"
							+ "<td>" + Math.round(onlineApp.getAmount().doubleValue() * 100.0) / 100.0 + "</td>"
							+ "<td>" + onlineApp.getPeriod() + "</td>" + "<td>" + onlineApp.getFullname() + "</td>"
							+ "<td>" + onlineApp.getBirthdate() + "</td>" + "<td>" + onlineApp.getPersonalNumber()
							+ "</td>" + "<td>" + onlineApp.getMobilephone() + "</td>" + "<td>"
							+ onlineApp.getWorkField() + "</td>" + "<td>" + onlineApp.getCompanyName() + "</td>"
							+ "<td>" + onlineApp.getPosition() + "</td>" + "<td>" + onlineApp.getSalary() + "</td>"
							+ "<td>" + getNameForStatus(onlineApp.getStatus()) + "</td>" + "</tr>"
							+ "<tr style=\"background-color:#85C1E9; height: 20px; font-weight: bold;\">"
							+ "<td>მუშ.ხან.</td>" + "<td>დამ.შემოსავალი</td>" + "<td>თვ.გადასახდელი</td>"
							+ "<td>ოჯახ.მდგომ.</td>" + "<td>შვილები</td>" + "<td>დასაქ.ოჯახ.წევრები</td>"
							+ "<td>საერთო შემოსავალი</td>" + "<td>თარიღი</td>" + "<td>ინკასო</td>"
							+ "<td align=\"center\">კომენტარები</td><td align=\"center\">აპლიკაციის დამატება</td><td align=\"center\">აპლიკაციის უარყოფა</td>"
							+ "</tr>" + "<tr>" + "<td>" + onlineApp.getWorkTime() + "</td>" + "<td>"
							+ onlineApp.getAdditionalIncome() + "</td>" + "<td>" + onlineApp.getLoanFreqAmount()
							+ "</td>" + "<td>" + onlineApp.getMaritalStatus() + "</td>" + "<td>"
							+ onlineApp.getChildren() + "</td>" + "<td>" + onlineApp.getWorkingRelatives() + "</td>"
							+ "<td>" + onlineApp.getTotalIncome() + "</td>" + "<td>"
							+ tf.millisecondsToDateStr(onlineApp.getAdditionTime()) +
							 "<td>"+(onlineApp.isIncaso() ? "ინკასო":"არ ადევს")+"</td>"
							+ "</td><td onclick=\"triggerComments(" + onlineApp.getOnlineAppId() + ","
							+ onlineApp.getCompany() + ")\"><img height=\"20px\" width=\"20px\" src=\""
							+ request.getContextPath() + "/resources/images/comment.png\"></td>"
							+ "<td bgcolor=\"lightgreen\" onclick=\"acceptApplication(" + onlineApp.getOnlineAppId()
							+ "," + onlineApp.getCompany() + ")\"><img height=\"20px\" width=\"20px\" src=\""
							+ request.getContextPath() + "/resources/images/accept.png\"></td>"
							+ "<td bgcolor=\"LightCoral\" onclick=\"rejectApplication(" + onlineApp.getOnlineAppId()
							+ "," + onlineApp.getCompany() + ")\"><img height=\"20px\" width=\"20px\" src=\""
							+ request.getContextPath() + "/resources/images/reject.png\"></td>" + "</tr>"
							+ "<tr><td colspan=\"3\">" + onlineApp.getLoanPurpose() + "</td><td colspan=\"5\">" + onlineApp.getBranch() + "</td></tr></table>" + "</table>"
							+ "<br>");
				} else {
					ret.append("<br>"
							+ "<table style=\"width:100%; height: 180px; border: 1px solid black; text-align:center; border-collapse: collapse; spacing: 5px;\">"
							+ "<tr style=\"background-color:#85C1E9; height: 20px; font-weight: bold;\">"
							+ "<td>ID</td>" + "<td>თანხა</td>" + "<td>პერიოდი</td>" + "<td>სახელი გვარი</td>"
							+ "<td>დაბ.თარიღი</td>" + "<td>პირადი ნომ.</td>" + "<td>მობილური</td>"
							+ "<td>სამუშაო სფერო</td>" + "<td>კომპანია</td>" + "<td>პოზიცია</td>" + "<td>ხელფასი</td>"
							+ "<td>სტატუსი</td>" + "</tr>" + "<tr>" + "<td>" + onlineApp.getOnlineAppId() + "</td>"
							+ "<td>" + Math.round(onlineApp.getAmount().doubleValue() * 100.0) / 100.0 + "</td>"
							+ "<td>" + onlineApp.getPeriod() + "</td>" + "<td>" + onlineApp.getFullname() + "</td>"
							+ "<td>" + onlineApp.getBirthdate() + "</td>" + "<td>" + onlineApp.getPersonalNumber()
							+ "</td>" + "<td>" + onlineApp.getMobilephone() + "</td>" + "<td>"
							+ onlineApp.getWorkField() + "</td>" + "<td>" + onlineApp.getCompanyName() + "</td>"
							+ "<td>" + onlineApp.getPosition() + "</td>" + "<td>" + onlineApp.getSalary() + "</td>"
							+ "<td>" + getNameForStatus(onlineApp.getStatus()) + "</td>" + "</tr>"
							+ "<tr style=\"background-color:#85C1E9; height: 20px; font-weight: bold;\">"
							+ "<td>მუშ.ხან.</td>" + "<td>დამ.შემოსავალი</td>" + "<td>თვ.გადასახდელი</td>"
							+ "<td>ოჯახ.მდგომ.</td>" + "<td>შვილები</td>" + "<td>დასაქ.ოჯახ.წევრები</td>"
							+ "<td>საერთო შემოსავალი</td>" + "<td>თარიღი</td>" + "<td>ინკასო</td>"
							+ "<td colspan=\"3\" align=\"center\">კომენტარები</td>" + "</tr>" + "<tr>" + "<td>"
							+ onlineApp.getWorkTime() + "</td>" + "<td>" + onlineApp.getAdditionalIncome() + "</td>"
							+ "<td>" + onlineApp.getLoanFreqAmount() + "</td>" + "<td>" + onlineApp.getMaritalStatus()
							+ "</td>" + "<td>" + onlineApp.getChildren() + "</td>" + "<td>"
							+ onlineApp.getWorkingRelatives() + "</td>" + "<td>" + onlineApp.getTotalIncome() + "</td>"
							+ "<td>" + tf.millisecondsToDateStr(onlineApp.getAdditionTime()) + "</td>" +
							"<td>"+(onlineApp.isIncaso() ? "ინკასო":"არ ადევს")+"</td>"
							+ "<td colspan=\"3\" onclick=\"triggerComments(" + onlineApp.getOnlineAppId() + ","
							+ onlineApp.getCompany() + ")\"><img height=\"20px\" width=\"20px\" src=\""
							+ request.getContextPath() + "/resources/images/comment.png\"></td>"
							+ ((onlineApp.getStatus() != 2) ? "<td colspan=\"3\" onclick=\"changeStatus("
									+ onlineApp.getOnlineAppId() + "," + onlineApp.getCompany() + "," + 0
									+ ")\"><img height=\"20px\" width=\"20px\" src=\"" + request.getContextPath()
									+ "/resources/images/resume.png\" title=\"აპლიკაციაში დაბრუნება\"></td>" : "")
							+ "</tr>" + "<tr><td colspan=\"3\">" + onlineApp.getLoanPurpose() + "</td><td colspan=\"5\">" + onlineApp.getBranch() + "</td></tr></table>"
							+ "</table>" + "<br>");
				}
			}
			for (OnlineApplicationForConsumerLoan onlineApp : onlineAppListCL) {
				// TODO: change below
				int consCompId = 2;
				if (onlineApp.getStatus() == 0) {
					ret.append("<br>"
							+ "<table style=\"width:100%; height: 180px; border: 1px solid black; text-align:center; border-collapse: collapse; spacing: 5px;\">"
							+ "<tr style=\"background-color:Coral; height: 20px; font-weight: bold;\">" + "<td>ID</td>"
							+ "<td>თანხა</td>" + "<td>პერიოდი</td>" + "<td>სახელი გვარი</td>" + "<td>დაბ.თარიღი</td>"
							+ "<td>პირადი ნომ.</td>" + "<td>მობილური</td>" + "<td>სამუშაო სფერო</td>"
							+ "<td>კომპანია</td>" + "<td>პოზიცია</td>" + "<td>ხელფასი</td>" + "<td>სტატუსი</td>"
							+ "</tr>" + "<tr>" + "<td>" + onlineApp.getId() + "</td>" + "<td>"
							+ Math.round(onlineApp.getLoanAmount() * 100.0) / 100.0 + "</td>" + "<td>"
							+ onlineApp.getLoanPeriod() + "</td>" + "<td>" + onlineApp.getName() + "</td>" + "<td>"
							+ onlineApp.getBirthDate() + "</td>" + "<td>" + onlineApp.getPrivateNumber() + "</td>"
							+ "<td>" + onlineApp.getMobileNumber() + "</td>" + "<td>" + onlineApp.getWorkSphere()
							+ "</td>" + "<td>" + onlineApp.getCompanyName() + "</td>" + "<td>"
							+ onlineApp.getWorkPosition() + "</td>" + "<td>" + onlineApp.getSalary() + "</td>" + "<td>"
							+ getNameForStatus(onlineApp.getStatus()) + "</td>" + "</tr>"
							+ "<tr style=\"background-color:Coral; height: 20px; font-weight: bold;\">"
							+ "<td>მუშ.ხან.</td>" + "<td>დამ.შემოსავალი</td>" + "<td>თვ.გადასახდელი</td>"
							+ "<td>ოჯახ.მდგომ.</td>" + "<td>შვილები</td>" + "<td>დასაქ.ოჯახ.წევრები</td>"
							+ "<td>საერთო შემოსავალი</td>" + "<td>თარიღი</td>" + "<td>ინკასო</td>" + "<td>დადასტურება</td>"
							+ "<td>უარყოფა</td>" + "<td>წაშლა</td>" + "</tr>" + "<tr>" + "<td>"
							+ onlineApp.getWorkPeriod() + "</td>" + "<td>" + onlineApp.getOtherIncome() + "</td>"
							+ "<td>" + onlineApp.getAmountToPayOnOtherLoans() + "</td>" + "<td>"
							+ onlineApp.getMaritalStatus() + "</td>" + "<td>" + onlineApp.getNumberOfChildren()
							+ "</td>" + "<td>" + onlineApp.getEmployedFamilyMembers() + "</td>" + "<td>"
							+ onlineApp.getTotalFamilyIncome() + "</td>" + "<td>"
							+ tf.millisecondsToDateStr(onlineApp.getAdditionTime()) + "</td>" +
							"<td>"+(onlineApp.isIncaso() ? "ინკასო":"არ ადევს")+"</td>"
							+ "<td bgcolor=\"lightgreen\" onclick=\"approveApplication(" + onlineApp.getId() + ","
							+ consCompId + ")\"><img height=\"20px\" width=\"20px\" src=\"" + request.getContextPath()
							+ "/resources/images/accept.png\"></td>"
							+ "<td bgcolor=\"LightCoral\" onclick=\"rejectApplication(" + onlineApp.getId() + ","
							+ consCompId + ")\"><img height=\"20px\" width=\"20px\" src=\"" + request.getContextPath()
							+ "/resources/images/reject.png\"></td>"
							+ "<td bgcolor=\"silver\" onclick=\"deleteApplication(" + onlineApp.getId() + ","
							+ consCompId + ")\"><img height=\"20px\" width=\"20px\" src=\"" + request.getContextPath()
							+ "/resources/images/delete.png\"></td>" + "</tr>"
							+ "<tr><td colspan=\"3\">"+onlineApp.getLoanPurpose()+"</td><td colspan=\"5\" align=\"left\"> " + onlineApp.getBranchOfficeName() + "</td></tr>"
							+ "</table>" + "<br>");
				} else if (onlineApp.getStatus() == 1) {
					ret.append("<br>"
							+ "<table style=\"width:100%; height: 180px; border: 1px solid black; text-align:center; border-collapse: collapse; spacing: 5px;\">"
							+ "<tr style=\"background-color:Coral; height: 20px; font-weight: bold;\">" + "<td>ID</td>"
							+ "<td>თანხა</td>" + "<td>პერიოდი</td>" + "<td>სახელი გვარი</td>" + "<td>დაბ.თარიღი</td>"
							+ "<td>პირადი ნომ.</td>" + "<td>მობილური</td>" + "<td>სამუშაო სფერო</td>"
							+ "<td>კომპანია</td>" + "<td>პოზიცია</td>" + "<td>ხელფასი</td>" + "<td>სტატუსი</td>"
							+ "</tr>" + "<tr>" + "<td>" + onlineApp.getId() + "</td>" + "<td>"
							+ Math.round(onlineApp.getLoanAmount() * 100.0) / 100.0 + "</td>" + "<td>"
							+ onlineApp.getLoanPeriod() + "</td>" + "<td>" + onlineApp.getName() + "</td>" + "<td>"
							+ onlineApp.getBirthDate() + "</td>" + "<td>" + onlineApp.getPrivateNumber() + "</td>"
							+ "<td>" + onlineApp.getMobileNumber() + "</td>" + "<td>" + onlineApp.getWorkSphere()
							+ "</td>" + "<td>" + onlineApp.getCompanyName() + "</td>" + "<td>"
							+ onlineApp.getWorkPosition() + "</td>" + "<td>" + onlineApp.getSalary() + "</td>" + "<td>"
							+ getNameForStatus(onlineApp.getStatus()) + "</td>" + "</tr>"
							+ "<tr style=\"background-color:Coral; height: 20px; font-weight: bold;\">"
							+ "<td>მუშ.ხან.</td>" + "<td>დამ.შემოსავალი</td>" + "<td>თვ.გადასახდელი</td>"
							+ "<td>ოჯახ.მდგომ.</td>" + "<td>შვილები</td>" + "<td>დასაქ.ოჯახ.წევრები</td>"
							+ "<td>საერთო შემოსავალი</td>" + "<td>თარიღი</td>" + "<td>ინკასო</td>"
							+ "<td align=\"center\">კომენტარები</td><td align=\"center\">აპლიკაციის დამატება</td><td align=\"center\">აპლიკაციის უარყოფა</td>"
							+ "</tr>" + "<tr>" + "<td>" + onlineApp.getWorkPeriod() + "</td>" + "<td>"
							+ onlineApp.getOtherIncome() + "</td>" + "<td>" + onlineApp.getAmountToPayOnOtherLoans()
							+ "</td>" + "<td>" + onlineApp.getMaritalStatus() + "</td>" + "<td>"
							+ onlineApp.getNumberOfChildren() + "</td>" + "<td>" + onlineApp.getEmployedFamilyMembers()
							+ "</td>" + "<td>" + onlineApp.getTotalFamilyIncome() + "</td>" +
							"<td>"+(onlineApp.isIncaso() ? "ინკასო":"არ ადევს")+"</td>" +
							"<td>" + tf.millisecondsToDateStr(onlineApp.getAdditionTime()) + "</td>"
							+ "<td onclick=\"triggerComments(" + onlineApp.getId() + "," + consCompId
							+ ")\"><img height=\"20px\" width=\"20px\" src=\"" + request.getContextPath()
							+ "/resources/images/comment.png\"></td>"
							+ "<td bgcolor=\"lightgreen\" onclick=\"acceptApplication(" + onlineApp.getId() + ","
							+ consCompId + ")\"><img height=\"20px\" width=\"20px\" src=\"" + request.getContextPath()
							+ "/resources/images/accept.png\"></td>"
							+ "<td bgcolor=\"LightCoral\" onclick=\"rejectApplication(" + onlineApp.getId() + ","
							+ consCompId + ")\"><img height=\"20px\" width=\"20px\" src=\"" + request.getContextPath()
							+ "/resources/images/reject.png\"></td>" + "</tr>"
							+ "<tr><td colspan=\"3\">" + onlineApp.getLoanPurpose() + "</td><td colspan=\"5\" align=\"left\"> " + onlineApp.getBranchOfficeName() + "</td></tr>"
							+ "</table>" + "<br>");
				} else {
					ret.append("<br>"
							+ "<table style=\"width:100%; height: 180px; border: 1px solid black; text-align:center; border-collapse: collapse; spacing: 5px;\">"
							+ "<tr style=\"background-color:Coral; height: 20px; font-weight: bold;\">" + "<td>ID</td>"
							+ "<td>თანხა</td>" + "<td>პერიოდი</td>" + "<td>სახელი გვარი</td>" + "<td>დაბ.თარიღი</td>"
							+ "<td>პირადი ნომ.</td>" + "<td>მობილური</td>" + "<td>სამუშაო სფერო</td>"
							+ "<td>კომპანია</td>" + "<td>პოზიცია</td>" + "<td>ხელფასი</td>" + "<td>სტატუსი</td>"
							+ "</tr>" + "<tr>" + "<td>" + onlineApp.getId() + "</td>" + "<td>"
							+ Math.round(onlineApp.getLoanAmount() * 100.0) / 100.0 + "</td>" + "<td>"
							+ onlineApp.getLoanPeriod() + "</td>" + "<td>" + onlineApp.getName() + "</td>" + "<td>"
							+ onlineApp.getBirthDate() + "</td>" + "<td>" + onlineApp.getPrivateNumber() + "</td>"
							+ "<td>" + onlineApp.getMobileNumber() + "</td>" + "<td>" + onlineApp.getWorkSphere()
							+ "</td>" + "<td>" + onlineApp.getCompanyName() + "</td>" + "<td>"
							+ onlineApp.getWorkPosition() + "</td>" + "<td>" + onlineApp.getSalary() + "</td>" + "<td>"
							+ getNameForStatus(onlineApp.getStatus()) + "</td>" + "</tr>"
							+ "<tr style=\"background-color:Coral; height: 20px; font-weight: bold;\">"
							+ "<td>მუშ.ხან.</td>" + "<td>დამ.შემოსავალი</td>" + "<td>თვ.გადასახდელი</td>"
							+ "<td>ოჯახ.მდგომ.</td>" + "<td>შვილები</td>" + "<td>დასაქ.ოჯახ.წევრები</td>"
							+ "<td>საერთო შემოსავალი</td>" + "<td>თარიღი</td>" + "<td>ინკასო</td>"
							+ "<td colspan=\"3\" align=\"center\">კომენტარები</td>" + "</tr>" + "<tr>" + "<td>"
							+ onlineApp.getWorkPeriod() + "</td>" + "<td>" + onlineApp.getOtherIncome() + "</td>"
							+ "<td>" + onlineApp.getAmountToPayOnOtherLoans() + "</td>" + "<td>"
							+ onlineApp.getMaritalStatus() + "</td>" + "<td>" + onlineApp.getNumberOfChildren()
							+ "</td>" + "<td>" + onlineApp.getEmployedFamilyMembers() + "</td>" + "<td>"
							+ onlineApp.getTotalFamilyIncome() + "</td>" + "<td>"
							+ "<td>"+(onlineApp.isIncaso() ? "ინკასო":"არ ადევს")+"</td>"
							+ tf.millisecondsToDateStr(onlineApp.getAdditionTime()) + "</td>"
							+ "<td colspan=\"3\" onclick=\"triggerComments(" + onlineApp.getId() + "," + consCompId
							+ ")\"><img height=\"20px\" width=\"20px\" src=\"" + request.getContextPath()
							+ "/resources/images/comment.png\"></td>"
							+ ((onlineApp.getStatus() != 2)
									? "<td colspan=\"4\" onclick=\"changeStatus(" + onlineApp.getId() + "," + consCompId
											+ "," + 0 + ")\"><img height=\"20px\" width=\"20px\" src=\""
											+ request.getContextPath()
											+ "/resources/images/resume.png\"  title=\"აპლიკაციაში დაბრუნება\"></td>"
									: "")
							+ "</tr>" + "<tr><td colspan=\"3\" align=\"left\"> " + onlineApp.getBranchOfficeName()
							+ "</td></tr>" + "</table>" + "<br>");
				}
			}
			return ret.toString();
		} catch (Exception e) {
			e.printStackTrace();
			return "სესხის სტატუსის შეცვლისას დაფიქსირდა შეცდომა: " + e.toString();
		}
	}
By Anonymous, 2017-11-06 09:59:23
Double value = item.getPrice() * loyaltyPointMultiplier;
String[] s = String.split(value.toString(), "\\.");
points = Integer.parseInt(s[0]);
if(Integer.parseInt(s[1]) > 0) {
    points++;
}
    
return points;

Want to round up? Math.ceil() uses too little memory! Use this instead!

By phytyca, 2017-12-12 05:02:48


public static MyClass {
    private static volatile ProcessManager singleton = null;
    
    public static ProcessManager getInstance() throws Exception {
        if (singleton == null) {
            synchronized (MyClass.class) {
                if (singleton == null) {
                    singleton = new ProcessManager();
                }
            }
        }
        return singleton;
    }
}

The double-checking was invented prior to Java5.

The purpose is if the field isn't null, you don't have to synchronize. But since the java memory model specification was cleaned up and Synchronize/Volatile were given much better specification and semantics it is totally useless boilerplate that you should only write if you have to support Java4. There is a Google Tech Talk that covers this.

By cody, 2017-12-12 08:02:01
Long timestamp = Instant.now().toEpochMilli(); // fallback
if (oTimestamp instanceof Integer)
    timestamp = (Integer) oTimestamp *1L;
else
    if (oTimestamp instanceof Long)
        timestamp = (Long) oTimestamp * 1L;
By Anonymous, 2017-12-12 08:13:40
switch (numberOfQuestionsToAnswer) {
        case 0:
            displayGrid1 = false;
            displayGrid2 = false;
            displayGrid3 = false;
            displayGrid4 = false;
            displayGrid5 = false;
            displayGrid6 = false;
            displayGrid7 = false;
            displayGrid8 = false;
            displayGrid9 = false;
            displayGrid10 = false;
            break;
        case 1:
            displayAnsInputTextBox1 = displayPreselectedAnsBox();
            displayGrid1 = true;
            break;
        case 2:
            displayAnsInputTextBox1 = displayPreselectedAnsBox();
            displayAnsInputTextBox2 = displayPreselectedAnsBox();
            displayGrid1 = true;
            displayGrid2 = true;
            break;
        case 3:
            displayAnsInputTextBox1 = displayPreselectedAnsBox();
            displayAnsInputTextBox2 = displayPreselectedAnsBox();
            displayAnsInputTextBox3 = displayPreselectedAnsBox();
            displayGrid1 = true;
            displayGrid2 = true;
            displayGrid3 = true;
            break;
        case 4:
            displayAnsInputTextBox1 = displayPreselectedAnsBox();
            displayAnsInputTextBox2 = displayPreselectedAnsBox();
            displayAnsInputTextBox3 = displayPreselectedAnsBox();
            displayAnsInputTextBox4 = displayPreselectedAnsBox();
            displayGrid1 = true;
            displayGrid2 = true;
            displayGrid3 = true;
            displayGrid4 = true;
            break;
        case 5:
            displayAnsInputTextBox1 = displayPreselectedAnsBox();
            displayAnsInputTextBox2 = displayPreselectedAnsBox();
            displayAnsInputTextBox3 = displayPreselectedAnsBox();
            displayAnsInputTextBox4 = displayPreselectedAnsBox();
            displayAnsInputTextBox5 = displayPreselectedAnsBox();
            displayGrid1 = true;
            displayGrid2 = true;
            displayGrid3 = true;
            displayGrid4 = true;
            displayGrid5 = true;
            break;
        case 6:
            displayAnsInputTextBox1 = displayPreselectedAnsBox();
            displayAnsInputTextBox2 = displayPreselectedAnsBox();
            displayAnsInputTextBox3 = displayPreselectedAnsBox();
            displayAnsInputTextBox4 = displayPreselectedAnsBox();
            displayAnsInputTextBox5 = displayPreselectedAnsBox();
            displayAnsInputTextBox6 = displayPreselectedAnsBox();
            displayGrid1 = true;
            displayGrid2 = true;
            displayGrid3 = true;
            displayGrid4 = true;
            displayGrid5 = true;
            displayGrid6 = true;
            break;
        case 7:
            displayAnsInputTextBox1 = displayPreselectedAnsBox();
            displayAnsInputTextBox2 = displayPreselectedAnsBox();
            displayAnsInputTextBox3 = displayPreselectedAnsBox();
            displayAnsInputTextBox4 = displayPreselectedAnsBox();
            displayAnsInputTextBox5 = displayPreselectedAnsBox();
            displayAnsInputTextBox6 = displayPreselectedAnsBox();
            displayAnsInputTextBox7 = displayPreselectedAnsBox();
            displayGrid1 = true;
            displayGrid2 = true;
            displayGrid3 = true;
            displayGrid4 = true;
            displayGrid5 = true;
            displayGrid6 = true;
            displayGrid7 = true;
            break;
        case 8:
            displayAnsInputTextBox1 = displayPreselectedAnsBox();
            displayAnsInputTextBox2 = displayPreselectedAnsBox();
            displayAnsInputTextBox3 = displayPreselectedAnsBox();
            displayAnsInputTextBox4 = displayPreselectedAnsBox();
            displayAnsInputTextBox5 = displayPreselectedAnsBox();
            displayAnsInputTextBox6 = displayPreselectedAnsBox();
            displayAnsInputTextBox7 = displayPreselectedAnsBox();
            displayAnsInputTextBox8 = displayPreselectedAnsBox();
            displayGrid1 = true;
            displayGrid2 = true;
            displayGrid3 = true;
            displayGrid4 = true;
            displayGrid5 = true;
            displayGrid6 = true;
            displayGrid7 = true;
            displayGrid8 = true;
            break;
        case 9:
            displayAnsInputTextBox1 = displayPreselectedAnsBox();
            displayAnsInputTextBox2 = displayPreselectedAnsBox();
            displayAnsInputTextBox3 = displayPreselectedAnsBox();
            displayAnsInputTextBox4 = displayPreselectedAnsBox();
            displayAnsInputTextBox5 = displayPreselectedAnsBox();
            displayAnsInputTextBox6 = displayPreselectedAnsBox();
            displayAnsInputTextBox7 = displayPreselectedAnsBox();
            displayAnsInputTextBox8 = displayPreselectedAnsBox();
            displayAnsInputTextBox9 = displayPreselectedAnsBox();
            displayGrid1 = true;
            displayGrid2 = true;
            displayGrid3 = true;
            displayGrid4 = true;
            displayGrid5 = true;
            displayGrid6 = true;
            displayGrid7 = true;
            displayGrid8 = true;
            displayGrid9 = true;
            break;
        case 10:
            displayAnsInputTextBox1 = displayPreselectedAnsBox();
            displayAnsInputTextBox2 = displayPreselectedAnsBox();
            displayAnsInputTextBox3 = displayPreselectedAnsBox();
            displayAnsInputTextBox4 = displayPreselectedAnsBox();
            displayAnsInputTextBox5 = displayPreselectedAnsBox();
            displayAnsInputTextBox6 = displayPreselectedAnsBox();
            displayAnsInputTextBox7 = displayPreselectedAnsBox();
            displayAnsInputTextBox8 = displayPreselectedAnsBox();
            displayAnsInputTextBox9 = displayPreselectedAnsBox();
            displayAnsInputTextBox10 = displayPreselectedAnsBox();
            displayGrid1 = true;
            displayGrid2 = true;
            displayGrid3 = true;
            displayGrid4 = true;
            displayGrid5 = true;
            displayGrid6 = true;
            displayGrid7 = true;
            displayGrid8 = true;
            displayGrid9 = true;
            displayGrid10 = true;
            break;
}

This was for a wizard type questionnaire where there could be up to 10 questions.

By Anonymous, 2017-12-12 10:57:52

"  ".split(" ");

Very weird code found multiple times in old code base.

By heldt, 2017-12-12 12:03:14
private HashMap<String, Tuple6<float[], String[], String[], String[], String[], String>> memberNameChangedToProtectTheInnocent = null;
By Anonymous, 2017-12-12 12:13:22
public static int[] sleepSort(int... args) {
        final int[] sorted = new int[args.length];
        final AtomicInteger index = new AtomicInteger(0);
        List<Thread> threads = new ArrayList<Thread>(0);
        for (int i = 0; i < args.length; i++) {
            final int x = i;
            Thread sorter = new Thread(() -> {
                try {
                    Thread.sleep(args[x]);
                } catch (InterruptedException ex) { 
                    // shrug
                }
                sorted[index.getAndIncrement()] = args[x];
            });
            sorter.setDaemon(true);
            sorter.start();
            threads.add(sorter);
        }
        try {
            for (Thread t : threads) { t.join(); }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return sorted;
    }

Takes an unsorted array of integers, sorts by sleeping for the int value of each item in the array and then writing that into the resulting sorted array. Big-O analysis is... difficult.

By Sum YungGui, 2017-12-12 17:10:56
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.


   O | O | O 
  -----------
   O | O | O 
  -----------
   O | O | O 
     

 */
package tictactoe;

import java.util.Scanner;

public class TicTacToe {

    /**
     * @param args the command line arguments
     * @throws java.lang.InterruptedException
     */
    public static void main(String[] args) throws InterruptedException {
        Scanner input = new Scanner(System.in);
        String a1 = "1";
        String a2 = "2";
        String a3 = "3";
        String a4 = "4";
        String a5 = "5";
        String a6 = "6";
        String a7 = "7";
        String a8 = "8";
        String a9 = "9";
        int inO;
        int inX = 0;
        boolean winner = false;
        PrintBoard(a1,a2,a3,a4,a5,a6,a7,a8,a9);
        System.out.printf("How to play - wait for your turn and when it comes write the number of the field that you want to draw in (from 1 to 9)\n");
        System.out.printf("Player O's turn: ");
        inO = input.nextInt();
        while (true) {
            switch (inO) {
                case 1:
                    if (a1 == "1") {
                        a1 = "O";
                    }
                    break;
                case 2:
                    if (a2 == "2") {
                    a2 = "O";
                    }
                    break;
                case 3:
                    if (a3 == "3") {
                    a3 = "O";
                    }
                    break;
                case 4:
                    if (a4 == "4") {
                    a4 = "O";
                    }
                    break;
                case 5:
                    if (a5 == "5") {
                    a5 = "O";
                    }
                    break;
                case 6:
                    if (a6 == "6") {
                    a6 = "O";
                    }
                    break;
                case 7:
                    if (a7 == "7") {
                    a7 = "O";
                    }
                    break;
                case 8:
                    if (a8 == "8") {
                    a8 = "O";                        
                    }
                    break;
                case 9:
                    if (a9 == "9") {
                    a9 = "O";
                    }
                    break;
                default:
                    System.out.printf("An error occured. Please accept it politely and restart the game.");
                    break;
            }
            System.out.printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
            if (null != Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9))switch (Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9)) {
                case "NONE":
                    if (a1 != "1" && a2 != "2" && a3 != "3" && a4 != "4" && a5 != "5" && a6 != "6" && a7 != "7" && a8 != "8" && a9 != "9") {
                        winner = true;
                        System.out.println("DRAW!");
                        Thread.sleep(3000);
                        break;
                    } else {
                    PrintBoard(a1,a2,a3,a4,a5,a6,a7,a8,a9);
                    System.out.printf("Player X's turn: ");
                    inX = input.nextInt();
                    break;
                    }
                case "X":
                    winner = true;
                    System.out.println("X HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                case "O":
                    winner = true;
                    System.out.printf("O HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                default:
                    break;
            }
            if (winner) {
                break;
            }
            switch (inX) {
                case 1:
                    if (a1 == "1") {
                    a1 = "X";
                    }
                    break;
                case 2:
                    if (a2 == "2") {
                    a2 = "X";
                    }
                    break;
                case 3:
                    if (a3 == "3") {
                    a3 = "X";
                    }
                    break;
                case 4:
                    if (a4 == "4") {
                    a4 = "X";
                    }
                    break;
                case 5:
                    if (a5 == "5") {
                    a5 = "X";
                    }
                    break;
                case 6:
                    if (a6 == "6") {
                    a6 = "X";
                    }
                    break;
                case 7:
                    if (a7 == "7") {
                    a7 = "X";
                    }
                    break;
                case 8:
                    if (a8 == "8") {
                    a8 = "X";
                    }
                    break;
                case 9:
                    if (a9 == "9") {
                    a9 = "X";
                    }
                    break;
                default:
                    System.out.printf("An error occured. Please accept it politely and restart the game.");
                    break;
            }
            System.out.printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
            if (null != Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9))switch (Winners(a1,a2,a3,a4,a5,a6,a7,a8,a9)) {
                case "NONE":
                    if (a1 != "1" && a2 != "2" && a3 != "3" && a4 != "4" && a5 != "5" && a6 != "6" && a7 != "7" && a8 != "8" && a9 != "9") {
                        winner = true;
                        System.out.println("DRAW!");
                        Thread.sleep(3000);
                        break;
                    } else {
                    PrintBoard(a1,a2,a3,a4,a5,a6,a7,a8,a9);
                    System.out.printf("Player O's turn: ");
                    inO = input.nextInt();
                    break;
                    }
                case "X":
                    winner = true;
                    System.out.println("X HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                case "O":
                    winner = true;
                    System.out.println("O HAS WON!!!");
                    Thread.sleep(3000);
                    break;
                default:
                    break;
            }
            if (winner) {
                break;
            }
        }    
    }
    
    public static void PrintBoard(String f1, String f2, String f3, String f4, String f5, String f6, String f7, String f8, String f9) {  
        System.out.printf("   %s | %s | %s \n",f1,f2,f3);
        System.out.printf("  ----------- \n");
        System.out.printf("   %s | %s | %s \n",f4,f5,f6);
        System.out.printf("  ----------- \n");
        System.out.printf("   %s | %s | %s \n",f7,f8,f9);
        System.out.printf(" \n");
    }
    
    public static String Winners(String f1, String f2, String f3, String f4, String f5, String f6, String f7, String f8, String f9) {
        if (f1 == f2 && f2 == f3 && f3 == "O") {
            return "O";
        } else if (f4 == f5 && f5 == f6 && f6 == "O") {
            return "O";
        } else if (f7 == f8 && f8 == f9 && f9 == "O") {
            return "O";
        } else if (f1 == f4 && f4 == f7 && f7 == "O") {
            return "O";
        } else if (f2 == f5 && f5 == f8 && f8 == "O") {
            return "O";
        } else if (f3 == f6 && f6 == f9 && f9 == "O") {
            return "O";
        } else if (f1 == f5 && f5 == f9 && f9 == "O") {
            return "O";
        } else if (f3 == f5 && f5 == f7 && f7 == "O") {
            return "O";
        } else if (f1 == f2 && f2 == f3 && f3 == "X") {
            return "X";
        } else if (f4 == f5 && f5 == f6 && f6 == "X") {
            return "X";
        } else if (f7 == f8 && f8 == f9 && f9 == "X") {
            return "X";
        } else if (f1 == f4 && f4 == f7 && f7 == "X") {
            return "X";
        } else if (f2 == f5 && f5 == f8 && f8 == "X") {
            return "X";
        } else if (f3 == f6 && f6 == f9 && f9 == "X") {
            return "X";
        } else if (f1 == f5 && f5 == f9 && f9 == "X") {
            return "X";
        } else if (f3 == f5 && f5 == f7 && f7 == "X") {
            return "X";
        } else {
            return "NONE";
        }
    }
}

There are sooo many problems with this...

By umnikos, 2017-12-12 17:27:24