Skip to content

Instantly share code, notes, and snippets.

View StringArrayToStringExample.java
package com.chankok.arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class StringArrayToStringExample {
public static void main(String[] args) {
// Initial the string array
View StringBufferExample.java
public class StringBufferExample {
public static void main(String[] args) {
StringBuffer strBuf = new StringBuffer();
// Append strings
strBuf.append("Welcome").append(' ').append("to").append(' ').append("Chankok.com");
System.out.println("Append strings : " + strBuf.toString());
@chankok
chankok / countries.json
Last active Oct 5, 2016
A JSON file with a list of country names and country codes (ISO Alpha-2)
View countries.json
[
{
"name": "Afghanistan",
"code": "AF"
},
{
"name": "Albania",
"code": "AL"
},
{
View Catch Multiple Exceptions in Java
// Syntax of catching multiple exceptions
Try {
// Execute statements that may throw exceptions
} catch (ExceptionType1 | ExceptionType2 | ... VariableName) {
// Handle exceptions
View StringBuilderExample.java
public class StringBuilderExample {
public static void main(String[] args) {
StringBuilder sb = new StringBuilder();
// Append strings
sb.append("Welcome").append(' ').append("to").append(' ').append("Chankok.com");
System.out.println("Append strings : " + sb.toString());
View DataEncapsulationExample.java
package com.chankok.oop;
public class DataEncapsulationExample {
public static void main(String[] args) {
try {
Student student1 = new Student();
student1.setName("Chankok");
View Java6ResourceManagementExample.java
package com.chankok.io;
import java.io.FileReader;
import java.io.IOException;
public class Java6ResourceManagementExample {
public static void main(String[] args) {
FileReader fr = null;
View CheckEvenOddNumberExample.java
package com.chankok.operators;
public class CheckEvenOddNumberExample {
public static void main(String[] args) {
// Initial the integer array
int[] intArrays = {-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5};
/*
View Java6ReadEntireFileExample.java
package com.chankok.io;
import java.io.FileReader;
import java.io.IOException;
public class Java6ReadEntireFileExample {
public static void main(String[] args) {
FileReader fr = null;
View README.md

web.xml Namespace Declaration and Schema Location Example

web.xml is the deployment descriptor for a Java web application.

We can specify the namespace declaration and schema location in web.xml file for different Java servlet version:

  • Java Servlet 3.1
  • Java Servlet 3.0
  • Java Servlet 2.5
  • Java Servlet 2.4