Could anybody help me - where is a problem?
package com.codegym.task.task22.task2208;
import java.util.*;
/*
Build a WHERE query
*/
public class Solution {
public static void main(String[] args) {
HashMap<String, String> mapka = new HashMap<String, String>();
mapka.put("name" ,"Johnson");
mapka.put("country", "USA");
mapka.put("city","Los Angeles");
mapka.put("age", null);
System.out.println(getQuery(mapka));
}
public static String getQuery(Map<String, String> params) {
String s = "";
for (Map.Entry<String, String> e: params.entrySet()){
if(e.getValue() ==null){
continue;
}else{
s += e.getKey()+" = '"+e.getValue()+"' and ";
}
}
StringBuilder sb = new StringBuilder(s);
int length = sb.length();
sb.replace(length -5,length, "");
return sb.toString();
}
}