Write a Java code that returns the same result as the following JavaScript function : JSON.stringify;
public static String stringify(JsonObject js) { String str = "{"; for (int i = 0; i < js.size(); i++) { Map.Entry<String, JsonValue> entry = js.get(i); str += entry.getKey() + ":" + entry.getValue(); if (i != js.size() - 1) { str += ","; } } return str + "}"; }