Skip to content

Instantly share code, notes, and snippets.

@JavaNoobPig
JavaNoobPig / Test1DimArrayEx2.java
Created June 9, 2018 08:42
Test1DimArrayEx2-2
package pig.review.jave;
public class Test1DimArrayEx2 {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++) {
System.out.println("args[" + i + "]=" + args[i]);
}
}
package pig.review.jave;
public class HWFibonaccSeries {
//FibonaccSeries => 0 1 1 2 3 5 8 13 21......
public void process(int nth){
long[] data =new long[nth];
for (int i=0;i<data.length;i++){
if (i<=1){
data[i]=i;
System.out.println(i+"th="+data[i]);
@JavaNoobPig
JavaNoobPig / Change_web.xml
Created July 5, 2018 01:01
Dynamic Web Module to 3.0 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>WebJDBC</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
@JavaNoobPig
JavaNoobPig / MJava_pom.xml
Created July 5, 2018 01:06
Modify Maven Project Java Version
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
//Tight Coupling Code Ex:
public interface SortAlgorithm {
}
public class BubbleSortAlgorithm implements SortAlgorithm {
}
public class ComplexBusinessService {
SortAlgorithm sortAlgorithm = new BubbleSortAlgorithm();
}
public class ComplexBusinessService {
SortAlgorithm sortAlgorithm;// = new BubbleSortAlgorithm();
public ComplexBusinessService(SortAlgorithm sortAlgorithm) {
this.sortAlgorithm=sortAlgorithm;
}
}
public class BubbleSortAlgorithm implements SortAlgorithm {
}
SortAlgorithm sortAlgorithm = new BubbleSortAlgorithm();
ComplexBusinessService bussinessService =
new ComplexBusinessService(sortAlgorithm);
<mirror>
<id>UK</id> <!--鏡像的識別ID-->
<name>Central</name> <!--該鏡像的名稱(沒什麼用)-->
<url>http://repo1.maven.org/maven2/</url> <!--該鏡像使用的遠程倉庫-->
<mirrorOf>*</mirrorOf> <!--取代的(遠程)倉庫對象,若填central,則會取代默認的http://repo1.maven.org/maven2-->
<!--上一行用單一星號代表取代所有有程倉庫(假設你有寫N個mirror的話)-->
</mirror>
@JavaNoobPig
JavaNoobPig / Maven_setting_spring.xml
Created July 25, 2018 09:01
修改後的Maven setting for spring
<mirrors>
<mirror>
<id>UK</id> <!--鏡像的識別ID-->
<name>Central</name> <!--該鏡像的名稱(沒什麼用)-->
<url>http://repo1.maven.org/maven2/</url> <!--該鏡像使用的遠程倉庫-->
<mirrorOf>*</mirrorOf> <!--取代的(遠程)倉庫對象,若填central,則會取代默認的http://repo1.maven.org/maven2-->
<!--上一行用單一星號代表取代所有有程倉庫(假設你有寫N個mirror的話)-->
</mirror>
<mirror>
@JavaNoobPig
JavaNoobPig / IntroductionSpring3_1.java
Created July 26, 2018 02:27
IntroductionSpring3_1
public interface SortAlgorithm {
public int[] sort(int[] numbers) ;
}