This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CreatNewInfo { | |
| private String password = "Mike"; | |
| private int age = 18; | |
| public String getPassword() { | |
| return password; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class keepScret { | |
| private int Account = 1000; // private 限制只能於該class使用 | |
| public String name = "Kia"; | |
| public void ShowInfo() { | |
| System.out.println("Account have:" + Account); | |
| System.out.println("Name:" + name); | |
| NotShow(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class parent { | |
| String name = "John"; | |
| public void sayHello() { | |
| System.out.println("Name=" + name); | |
| } | |
| } | |
| class child extends parent { | |
| String anotherone = name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component | |
| @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) | |
| public class BinarySearchImpl { | |
| @Autowired | |
| @Qualifier("bubble") | |
| private SortAlgorithm sortAlgorithm; | |
| public int binarySearch(int [] numbers,int numberToSearchFor) { | |
| int[] sortedNumbers = sortAlgorithm.sort(numbers); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Component | |
| @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) | |
| public class BinarySearchImpl { | |
| @Autowired | |
| @Qualifier("bubble") | |
| private SortAlgorithm sortAlgorithm; | |
| public int binarySearch(int [] numbers,int numberToSearchFor) { | |
| int[] sortedNumbers = sortAlgorithm.sort(numbers); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.basics.springin5steps; | |
| import org.springframework.boot.SpringApplication; | |
| import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| import org.springframework.context.ApplicationContext; | |
| @SpringBootApplication | |
| public class SpringIn5StepsApplication { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.basics.springin5steps; | |
| public interface SortAlgorithm { | |
| public int[] sort(int[] numbers) ; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.basics.springin5steps; | |
| import org.springframework.beans.factory.annotation.Autowired; | |
| import org.springframework.beans.factory.annotation.Qualifier; | |
| import org.springframework.beans.factory.config.ConfigurableBeanFactory; | |
| import org.springframework.context.annotation.Scope; | |
| import org.springframework.stereotype.Component; | |
| @Component | |
| @Scope(ConfigurableBeanFactory.SCOPE_SINGLETON) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.basics.springin5steps; | |
| import org.springframework.beans.factory.annotation.Qualifier; | |
| import org.springframework.context.annotation.Primary; | |
| import org.springframework.stereotype.Component; | |
| @Component | |
| @Qualifier("bubble") | |
| public class BubbleSortAlgorithm implements SortAlgorithm{ | |
| public int[] sort(int[] numbers) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.pig.spring.basics.springin5steps; | |
| import org.springframework.beans.factory.annotation.Qualifier; | |
| import org.springframework.context.annotation.Primary; | |
| import org.springframework.stereotype.Component; | |
| @Component | |
| @Qualifier("quick") | |
| public class QuickSortAlgorithm implements SortAlgorithm{ |