Hustling and Buzzing with Java (Simple Sample coding by Barley and Malt (Brewed, Homebrewed,Blended and Single) Holistic Student aged 36) [Not drunk on business days {Studying at school -days}]

Source code:

import java.util.*;
import org.json.*;


public class Testi {

//Attributes
private Map<String, String> relations = new HashMap<String, String>();
private String finalJSON;

//Constructor
public Testi() {
generateKeysAndValues();
generateJSON();
}

//setters and getters
public void setFinalJSON(String x) {
this.finalJSON = x;

}

public String getFinalJSON() {
return this.finalJSON;
}

//Other Methods
public void generateKeysAndValues() {
String key = “STUDENT”;
String values =”001,John,Smith”;
relations.put(key, values);
}

public void generateJSON() {
JSONStringer x = new JSONStringer();
Collection colle = relations.values();
Object[] sArr = colle.toArray();
x.object().key(“STUDENT”).value((String)sArr[0]).endObject();
this.setFinalJSON(x.toString());
}

//Overriding String-method
public String toString() {
return “” +this.getFinalJSON();
}

public void run() {
System.out.println (this.toString());
}

public static void main(String[] args) {
Testi testApp = new Testi();
testApp.run();
}
}

Output (JSON Notational):

{"STUDENT":"001,John,Smith"}

About Jere Sumell

Graduated in February 2017 at the degree program of Bachleor of Business and Administration in Information Technology at Turku Univerity of Applied Sciences. At the end of the last semester I started to be a sole trader for my private projects and I'm officially taking public action in Politics through the Left Alliance in Finland. I'm the member of the Left Alliance Educational Division. I did the takedown my current business activities at the 31.5.2018 (Mostly responsive web developement orders based on CMS-solutions was the works some enterpeurers ordered from me.) I'm article writer in my Computer -related blog @ Wordpress. My first appearance at Wordpress blogs was our IT-student team blog called "The Gr8 Tigers".
This entry was posted in Blogi, Hupi, Internet, Linux, Ohjelmat, Ohjelmointi, Tietokannat, Tulevaisuus, Turvallisuus. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s