├── JavaStudy ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── bin │ ├── .gitignore │ ├── HelloWorld.class │ ├── MapTest.class │ ├── ThreadLocalDemo$Accessor.class │ ├── ThreadLocalDemo$ThreadLocalVariableHolder$1.class │ ├── ThreadLocalDemo$ThreadLocalVariableHolder.class │ ├── ThreadLocalDemo.class │ ├── com │ │ ├── algorithm │ │ │ ├── KMP │ │ │ │ └── KMP.class │ │ │ ├── niukecoder │ │ │ │ ├── BFS$TreeNode.class │ │ │ │ ├── BFS.class │ │ │ │ ├── Fibonacci.class │ │ │ │ ├── FindKthToTail.class │ │ │ │ ├── FindPath$TreeNode.class │ │ │ │ ├── FindPath.class │ │ │ │ ├── HasSubtree$TreeNode.class │ │ │ │ ├── HasSubtree.class │ │ │ │ ├── JumpFloor.class │ │ │ │ ├── JumpFloorII.class │ │ │ │ ├── ListNode.class │ │ │ │ ├── MergeList$ListNode.class │ │ │ │ ├── MergeList.class │ │ │ │ ├── MinNumberInRotateArray.class │ │ │ │ ├── MirrorTree$TreeNode.class │ │ │ │ ├── MirrorTree.class │ │ │ │ ├── MyStack.class │ │ │ │ ├── NumberOf1.class │ │ │ │ ├── Power.class │ │ │ │ ├── PrintFromTopToBottom$TreeNode.class │ │ │ │ ├── PrintFromTopToBottom.class │ │ │ │ ├── PrintListFromTailToHead$ListNode.class │ │ │ │ ├── PrintListFromTailToHead.class │ │ │ │ ├── PrintMatrix.class │ │ │ │ ├── ReOrderArray.class │ │ │ │ ├── RectCover.class │ │ │ │ ├── ReplaceSpace.class │ │ │ │ ├── ReverseList.class │ │ │ │ ├── SortedArrayFind.class │ │ │ │ ├── StackPopOrder.class │ │ │ │ ├── StackReplaceQueue.class │ │ │ │ └── VerifySquenceOfBST.class │ │ │ └── sort │ │ │ │ ├── ArrayUtils.class │ │ │ │ ├── BubbleSort.class │ │ │ │ ├── ChoiceSort.class │ │ │ │ ├── HeapSort.class │ │ │ │ ├── InsertSort.class │ │ │ │ ├── MergeSort.class │ │ │ │ ├── QuickSort.class │ │ │ │ └── ShellSort.class │ │ ├── dataStructure │ │ │ ├── Enum │ │ │ │ ├── TestEnum$ColorEnum.class │ │ │ │ ├── TestEnum$OrderEnum$1.class │ │ │ │ ├── TestEnum$OrderEnum$2.class │ │ │ │ ├── TestEnum$OrderEnum$3.class │ │ │ │ ├── TestEnum$OrderEnum$4.class │ │ │ │ ├── TestEnum$OrderEnum$5.class │ │ │ │ ├── TestEnum$OrderEnum$6.class │ │ │ │ ├── TestEnum$OrderEnum$7.class │ │ │ │ ├── TestEnum$OrderEnum.class │ │ │ │ ├── TestEnum$SeasonEnum.class │ │ │ │ ├── TestEnum$SexEnum.class │ │ │ │ └── TestEnum.class │ │ │ └── map │ │ │ │ └── MapUtil.class │ │ ├── designPattern │ │ │ ├── abtractFactory │ │ │ │ ├── AbtractGenerator.class │ │ │ │ ├── AndroidPad.class │ │ │ │ ├── AndroidPhone.class │ │ │ │ ├── IAbtractGenerator.class │ │ │ │ ├── IPad.class │ │ │ │ ├── IPhone.class │ │ │ │ ├── IosPad.class │ │ │ │ ├── IosPhone.class │ │ │ │ └── MainClient.class │ │ │ ├── builder │ │ │ │ ├── Person$Builder.class │ │ │ │ ├── Person.class │ │ │ │ └── TestBuilder.class │ │ │ ├── factory │ │ │ │ ├── AndroidGenerator.class │ │ │ │ ├── AndroidPhone.class │ │ │ │ ├── IGenerator.class │ │ │ │ ├── IPhone.class │ │ │ │ ├── IosGenertor.class │ │ │ │ ├── IosPhone.class │ │ │ │ └── MainClient.class │ │ │ ├── javaObserve │ │ │ │ ├── TestObserver.class │ │ │ │ ├── Watched.class │ │ │ │ └── Watcher.class │ │ │ ├── nativeObserve │ │ │ │ ├── Observable.class │ │ │ │ ├── Observe.class │ │ │ │ ├── ObserveData.class │ │ │ │ ├── TestObserve$1.class │ │ │ │ ├── TestObserve$2.class │ │ │ │ └── TestObserve.class │ │ │ ├── proto │ │ │ │ ├── Person.class │ │ │ │ └── TestProto.class │ │ │ ├── proxy │ │ │ │ ├── Client.class │ │ │ │ ├── ProxyManager.class │ │ │ │ ├── UserManager.class │ │ │ │ ├── UserManagerImpl.class │ │ │ │ └── UserManagerProxy.class │ │ │ ├── simpleFactory │ │ │ │ ├── AndroidPhone.class │ │ │ │ ├── IPhone.class │ │ │ │ ├── IReflectGenerator.class │ │ │ │ ├── IosPhone.class │ │ │ │ ├── MainClient.class │ │ │ │ ├── PhoneGenerator.class │ │ │ │ └── ReflectPhoneGenerator.class │ │ │ ├── singleton │ │ │ │ ├── EnumSingleTon.class │ │ │ │ ├── HungerSingleTon.class │ │ │ │ ├── LazySingleTon.class │ │ │ │ ├── MultiLazySingleTon.class │ │ │ │ ├── StaticClassSingleTon$StaticClassSingleTonHolder.class │ │ │ │ └── StaticClassSingleTon.class │ │ │ └── strategy │ │ │ │ ├── PlaneStrategy.class │ │ │ │ ├── Strategy.class │ │ │ │ ├── StrategyContext.class │ │ │ │ ├── TestStrategy.class │ │ │ │ └── WalkStrategy.class │ │ ├── java │ │ │ ├── generic │ │ │ │ ├── GenericClass$Box.class │ │ │ │ ├── GenericClass.class │ │ │ │ ├── GenericFunction.class │ │ │ │ ├── GenericInterface.class │ │ │ │ ├── GenericSpecial$Box1.class │ │ │ │ ├── GenericSpecial.class │ │ │ │ └── InterfaceTest.class │ │ │ ├── inject │ │ │ │ ├── Apple.class │ │ │ │ ├── FruitColor$Color.class │ │ │ │ ├── FruitColor.class │ │ │ │ ├── FruitName.class │ │ │ │ ├── FruitProvider.class │ │ │ │ └── MainClient.class │ │ │ └── reflect │ │ │ │ ├── TestReflect.class │ │ │ │ ├── UserManager.class │ │ │ │ └── UserManagerImpl.class │ │ └── webcrawler │ │ │ └── simple │ │ │ └── Test.class │ └── commons-lang.jar └── src │ ├── HelloWorld.java │ ├── MapTest.java │ ├── ThreadLocalDemo.java │ ├── com │ ├── algorithm │ │ ├── KMP │ │ │ └── KMP.java │ │ ├── leetcode │ │ │ ├── KMP.java │ │ │ ├── Sub10_RegularExpressionMatching.java │ │ │ ├── Sub1_TwoSum.java │ │ │ ├── Sub2_AddTwoNumbers.java │ │ │ ├── Sub3_LongestSubstringWithoutRepeatingCharacters.java │ │ │ ├── Sub4_MedianofTwoSortedArrays.java │ │ │ ├── Sub5_LongestPalindromicSubstring.java │ │ │ ├── Sub6_ZigZagConversion.java │ │ │ ├── Sub7_ReverseInteger.java │ │ │ ├── Sub8_StringtoInteger.java │ │ │ └── Sub9_PalindromeNumber.java │ │ ├── niukecoder │ │ │ ├── BFS.java │ │ │ ├── Fibonacci.java │ │ │ ├── FindKthToTail.java │ │ │ ├── FindPath.java │ │ │ ├── HasSubtree.java │ │ │ ├── JumpFloor.java │ │ │ ├── JumpFloorII.java │ │ │ ├── MergeList.java │ │ │ ├── MinNumberInRotateArray.java │ │ │ ├── MirrorTree.java │ │ │ ├── MyStack.java │ │ │ ├── NumberOf1.java │ │ │ ├── Power.java │ │ │ ├── PrintFromTopToBottom.java │ │ │ ├── PrintListFromTailToHead.java │ │ │ ├── PrintMatrix.java │ │ │ ├── ReOrderArray.java │ │ │ ├── RectCover.java │ │ │ ├── ReplaceSpace.java │ │ │ ├── ReverseList.java │ │ │ ├── SortedArrayFind.java │ │ │ ├── StackPopOrder.java │ │ │ ├── StackReplaceQueue.java │ │ │ └── VerifySquenceOfBST.java │ │ └── sort │ │ │ ├── ArrayUtils.java │ │ │ ├── BubbleSort.java │ │ │ ├── ChoiceSort.java │ │ │ ├── HeapSort.java │ │ │ ├── InsertSort.java │ │ │ ├── MergeSort.java │ │ │ ├── QuickSort.java │ │ │ └── ShellSort.java │ ├── dataStructure │ │ ├── Enum │ │ │ └── TestEnum.java │ │ └── map │ │ │ └── MapUtil.java │ ├── designPattern │ │ ├── abtractFactory │ │ │ ├── AbtractGenerator.java │ │ │ ├── AndroidPad.java │ │ │ ├── AndroidPhone.java │ │ │ ├── IAbtractGenerator.java │ │ │ ├── IPad.java │ │ │ ├── IPhone.java │ │ │ ├── IosPad.java │ │ │ ├── IosPhone.java │ │ │ └── MainClient.java │ │ ├── adapter │ │ │ ├── Adaptee.java │ │ │ ├── Client.java │ │ │ ├── InheritAdapter.java │ │ │ ├── Target.java │ │ │ └── WrapAdapter.java │ │ ├── builder │ │ │ ├── Person.java │ │ │ └── TestBuilder.java │ │ ├── command │ │ │ ├── ChangeChannelCommand.java │ │ │ ├── Client.java │ │ │ ├── Command.java │ │ │ ├── Invoke.java │ │ │ ├── TurnOffCommand.java │ │ │ ├── TurnOnCommand.java │ │ │ └── Tv.java │ │ ├── component │ │ │ ├── BaiYunMarket.java │ │ │ ├── Client.java │ │ │ ├── GuangzhouMarket.java │ │ │ ├── Market.java │ │ │ └── TianHeMarket.java │ │ ├── decorator │ │ │ ├── Client.java │ │ │ ├── Decorator.java │ │ │ ├── Human.java │ │ │ ├── Person.java │ │ │ ├── SecondDecorator.java │ │ │ ├── ThirdDecorator.java │ │ │ └── firstDecorator.java │ │ ├── facade │ │ │ ├── ModuleA.java │ │ │ ├── ModuleB.java │ │ │ ├── ModuleC.java │ │ │ └── ModuleFacade.java │ │ ├── factory │ │ │ ├── AndroidGenerator.java │ │ │ ├── AndroidPhone.java │ │ │ ├── IGenerator.java │ │ │ ├── IPhone.java │ │ │ ├── IosGenertor.java │ │ │ ├── IosPhone.java │ │ │ └── MainClient.java │ │ ├── flyweight │ │ │ ├── Client.java │ │ │ ├── ConcreteFlyweight.java │ │ │ ├── Flyweight.java │ │ │ └── FlyweightFactory.java │ │ ├── handler │ │ │ ├── Client.java │ │ │ ├── DeptManager.java │ │ │ ├── GeneralManager.java │ │ │ ├── Handler.java │ │ │ └── ProjectManager.java │ │ ├── javaObserve │ │ │ ├── TestObserver.java │ │ │ ├── Watched.java │ │ │ └── Watcher.java │ │ ├── nativeObserve │ │ │ ├── Observable.java │ │ │ ├── Observe.java │ │ │ ├── ObserveData.java │ │ │ └── TestObserve.java │ │ ├── proto │ │ │ ├── Person.java │ │ │ └── TestProto.java │ │ ├── proxy │ │ │ ├── Client.java │ │ │ ├── ProxyManager.java │ │ │ ├── UserManager.java │ │ │ ├── UserManagerImpl.java │ │ │ └── UserManagerProxy.java │ │ ├── simpleFactory │ │ │ ├── AndroidPhone.java │ │ │ ├── IPhone.java │ │ │ ├── IReflectGenerator.java │ │ │ ├── IosPhone.java │ │ │ ├── MainClient.java │ │ │ ├── PhoneGenerator.java │ │ │ └── ReflectPhoneGenerator.java │ │ ├── singleton │ │ │ ├── EnumSingleTon.java │ │ │ ├── HungerSingleTon.java │ │ │ ├── LazySingleTon.java │ │ │ ├── MultiLazySingleTon.java │ │ │ └── StaticClassSingleTon.java │ │ ├── state │ │ │ ├── VoteContext.java │ │ │ └── VoteState.java │ │ └── strategy │ │ │ ├── PlaneStrategy.java │ │ │ ├── Strategy.java │ │ │ ├── StrategyContext.java │ │ │ ├── TestStrategy.java │ │ │ └── WalkStrategy.java │ ├── java │ │ ├── generic │ │ │ ├── GenericClass.java │ │ │ ├── GenericFunction.java │ │ │ ├── GenericInterface.java │ │ │ ├── GenericSpecial.java │ │ │ └── InterfaceTest.java │ │ ├── inject │ │ │ ├── Apple.java │ │ │ ├── FruitColor.java │ │ │ ├── FruitName.java │ │ │ ├── FruitProvider.java │ │ │ └── MainClient.java │ │ └── reflect │ │ │ ├── TestReflect.java │ │ │ ├── UserManager.java │ │ │ └── UserManagerImpl.java │ └── webcrawler │ │ └── simple │ │ └── Test.java │ └── commons-lang.jar ├── MyUtil ├── .gitignore ├── .idea │ ├── compiler.xml │ ├── copyright │ │ └── profiles_settings.xml │ ├── gradle.xml │ ├── inspectionProfiles │ │ ├── Project_Default.xml │ │ └── profiles_settings.xml │ ├── misc.xml │ ├── modules.xml │ └── runConfigurations.xml ├── app │ ├── .gitignore │ ├── build.gradle │ ├── proguard-rules.pro │ └── src │ │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── common │ │ │ └── myutil │ │ │ └── ExampleInstrumentedTest.java │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── common │ │ │ │ └── myutil │ │ │ │ ├── ActivityList.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── activity │ │ │ │ └── GLActivity.java │ │ │ │ ├── articleListAdapter.java │ │ │ │ ├── base │ │ │ │ ├── BaseDialog.java │ │ │ │ └── BaseSharePreferences.java │ │ │ │ ├── dialog │ │ │ │ └── ExampleDialog.java │ │ │ │ ├── eventbus │ │ │ │ ├── Event.java │ │ │ │ ├── EventBus.java │ │ │ │ ├── EventBusActivity.java │ │ │ │ ├── Item.java │ │ │ │ ├── ItemDetailFragment.java │ │ │ │ └── ItemListFragment.java │ │ │ │ ├── exmple │ │ │ │ ├── ParcelableUser.java │ │ │ │ └── SerializableUser.java │ │ │ │ ├── inject │ │ │ │ ├── DynamicHandler.java │ │ │ │ ├── EventBase.java │ │ │ │ ├── InjectActivity.java │ │ │ │ ├── OnClick.java │ │ │ │ ├── OnLongClick.java │ │ │ │ └── ViewInjectUtils.java │ │ │ │ ├── sharepreferences │ │ │ │ └── VoiceAutoPlayPreferences.java │ │ │ │ ├── utils │ │ │ │ ├── AppUtils.java │ │ │ │ ├── DateUtils.java │ │ │ │ ├── DensityUtils.java │ │ │ │ ├── DeviceUtils.java │ │ │ │ ├── EnCodeUtils.java │ │ │ │ ├── LogUtils.java │ │ │ │ ├── NetworkUtils.java │ │ │ │ ├── NumberUitls.java │ │ │ │ ├── SoundPoolPlayer.java │ │ │ │ └── quickadapter │ │ │ │ │ ├── FNBaseAdapterHelper.java │ │ │ │ │ ├── FNBaseQuickAdapter.java │ │ │ │ │ ├── FNEnchangedQuickAdapter.java │ │ │ │ │ ├── FNMultiItemTypeSupport.java │ │ │ │ │ └── FNQuickAdapter.java │ │ │ │ ├── view │ │ │ │ ├── AnimateActivity.java │ │ │ │ ├── AnimateView.java │ │ │ │ └── DemoSurfaceView.java │ │ │ │ └── widget │ │ │ │ └── FNFlowLayout.java │ │ └── res │ │ │ ├── drawable-xhdpi │ │ │ ├── beginstudy.png │ │ │ ├── bg_dialog_content.9.png │ │ │ ├── bg_dialog_title.png │ │ │ ├── bg_edit.9.png │ │ │ ├── btn_orange.9.png │ │ │ └── g_white.png │ │ │ ├── layout │ │ │ ├── activity_eventbus.xml │ │ │ ├── activity_gl.xml │ │ │ ├── activity_inject.xml │ │ │ ├── activity_item_detail.xml │ │ │ ├── activity_item_list.xml │ │ │ ├── activity_main.xml │ │ │ ├── article_item.xml │ │ │ ├── dialog_enter_room.xml │ │ │ └── fragment_item_detail.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ │ └── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ └── test │ │ └── java │ │ └── com │ │ └── common │ │ └── myutil │ │ └── ExampleUnitTest.java ├── build.gradle ├── cache.txt ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── projectFilesBackup │ └── .idea │ │ └── workspace.xml └── settings.gradle ├── README.md └── study ├── Lottie动画库的使用.docx ├── Retrofit2+RxJava+Gson的使用.docx ├── android 6.0权限申请.docx ├── android 动画被父布局遮盖问题解决.docx ├── android适配方案.docx ├── getName()和getSimpleName()的区别.docx ├── handler机制.docx ├── volatile的使用.docx ├── 事件分发机制.docx ├── 代理模式.docx ├── 华为手机日志打开.docx ├── 反射.docx ├── 泛型.docx ├── 编码浅析.docx └── 自定义view滑动.docx /JavaStudy/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /JavaStudy/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | JavaStudy 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /JavaStudy/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/HelloWorld.java=UTF-8 3 | encoding/=UTF-8 4 | -------------------------------------------------------------------------------- /JavaStudy/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.8 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.source=1.8 12 | -------------------------------------------------------------------------------- /JavaStudy/bin/.gitignore: -------------------------------------------------------------------------------- 1 | /com/ 2 | -------------------------------------------------------------------------------- /JavaStudy/bin/HelloWorld.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/HelloWorld.class -------------------------------------------------------------------------------- /JavaStudy/bin/MapTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/MapTest.class -------------------------------------------------------------------------------- /JavaStudy/bin/ThreadLocalDemo$Accessor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/ThreadLocalDemo$Accessor.class -------------------------------------------------------------------------------- /JavaStudy/bin/ThreadLocalDemo$ThreadLocalVariableHolder$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/ThreadLocalDemo$ThreadLocalVariableHolder$1.class -------------------------------------------------------------------------------- /JavaStudy/bin/ThreadLocalDemo$ThreadLocalVariableHolder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/ThreadLocalDemo$ThreadLocalVariableHolder.class -------------------------------------------------------------------------------- /JavaStudy/bin/ThreadLocalDemo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/ThreadLocalDemo.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/KMP/KMP.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/KMP/KMP.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/BFS$TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/BFS$TreeNode.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/BFS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/BFS.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/Fibonacci.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/Fibonacci.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/FindKthToTail.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/FindKthToTail.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/FindPath$TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/FindPath$TreeNode.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/FindPath.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/FindPath.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/HasSubtree$TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/HasSubtree$TreeNode.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/HasSubtree.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/HasSubtree.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/JumpFloor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/JumpFloor.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/JumpFloorII.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/JumpFloorII.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/ListNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/ListNode.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/MergeList$ListNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/MergeList$ListNode.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/MergeList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/MergeList.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/MinNumberInRotateArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/MinNumberInRotateArray.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/MirrorTree$TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/MirrorTree$TreeNode.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/MirrorTree.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/MirrorTree.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/MyStack.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/MyStack.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/NumberOf1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/NumberOf1.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/Power.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/Power.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/PrintFromTopToBottom$TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/PrintFromTopToBottom$TreeNode.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/PrintFromTopToBottom.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/PrintFromTopToBottom.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/PrintListFromTailToHead$ListNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/PrintListFromTailToHead$ListNode.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/PrintListFromTailToHead.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/PrintListFromTailToHead.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/PrintMatrix.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/PrintMatrix.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/ReOrderArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/ReOrderArray.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/RectCover.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/RectCover.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/ReplaceSpace.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/ReplaceSpace.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/ReverseList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/ReverseList.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/SortedArrayFind.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/SortedArrayFind.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/StackPopOrder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/StackPopOrder.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/StackReplaceQueue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/StackReplaceQueue.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/niukecoder/VerifySquenceOfBST.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/niukecoder/VerifySquenceOfBST.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/sort/ArrayUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/sort/ArrayUtils.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/sort/BubbleSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/sort/BubbleSort.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/sort/ChoiceSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/sort/ChoiceSort.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/sort/HeapSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/sort/HeapSort.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/sort/InsertSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/sort/InsertSort.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/sort/MergeSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/sort/MergeSort.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/sort/QuickSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/sort/QuickSort.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/algorithm/sort/ShellSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/algorithm/sort/ShellSort.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum$ColorEnum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum$ColorEnum.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$1.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$2.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$3.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$4.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$5.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$6.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$6.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$7.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum$7.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum$OrderEnum.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum$SeasonEnum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum$SeasonEnum.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum$SexEnum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum$SexEnum.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/Enum/TestEnum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/Enum/TestEnum.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/dataStructure/map/MapUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/dataStructure/map/MapUtil.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/abtractFactory/AbtractGenerator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/abtractFactory/AbtractGenerator.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/abtractFactory/AndroidPad.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/abtractFactory/AndroidPad.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/abtractFactory/AndroidPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/abtractFactory/AndroidPhone.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/abtractFactory/IAbtractGenerator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/abtractFactory/IAbtractGenerator.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/abtractFactory/IPad.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/abtractFactory/IPad.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/abtractFactory/IPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/abtractFactory/IPhone.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/abtractFactory/IosPad.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/abtractFactory/IosPad.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/abtractFactory/IosPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/abtractFactory/IosPhone.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/abtractFactory/MainClient.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/abtractFactory/MainClient.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/builder/Person$Builder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/builder/Person$Builder.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/builder/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/builder/Person.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/builder/TestBuilder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/builder/TestBuilder.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/factory/AndroidGenerator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/factory/AndroidGenerator.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/factory/AndroidPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/factory/AndroidPhone.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/factory/IGenerator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/factory/IGenerator.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/factory/IPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/factory/IPhone.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/factory/IosGenertor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/factory/IosGenertor.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/factory/IosPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/factory/IosPhone.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/factory/MainClient.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/factory/MainClient.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/javaObserve/TestObserver.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/javaObserve/TestObserver.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/javaObserve/Watched.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/javaObserve/Watched.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/javaObserve/Watcher.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/javaObserve/Watcher.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/nativeObserve/Observable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/nativeObserve/Observable.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/nativeObserve/Observe.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/nativeObserve/Observe.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/nativeObserve/ObserveData.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/nativeObserve/ObserveData.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/nativeObserve/TestObserve$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/nativeObserve/TestObserve$1.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/nativeObserve/TestObserve$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/nativeObserve/TestObserve$2.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/nativeObserve/TestObserve.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/nativeObserve/TestObserve.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/proto/Person.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/proto/Person.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/proto/TestProto.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/proto/TestProto.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/proxy/Client.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/proxy/Client.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/proxy/ProxyManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/proxy/ProxyManager.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/proxy/UserManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/proxy/UserManager.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/proxy/UserManagerImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/proxy/UserManagerImpl.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/proxy/UserManagerProxy.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/proxy/UserManagerProxy.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/simpleFactory/AndroidPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/simpleFactory/AndroidPhone.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/simpleFactory/IPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/simpleFactory/IPhone.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/simpleFactory/IReflectGenerator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/simpleFactory/IReflectGenerator.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/simpleFactory/IosPhone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/simpleFactory/IosPhone.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/simpleFactory/MainClient.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/simpleFactory/MainClient.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/simpleFactory/PhoneGenerator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/simpleFactory/PhoneGenerator.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/simpleFactory/ReflectPhoneGenerator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/simpleFactory/ReflectPhoneGenerator.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/singleton/EnumSingleTon.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/singleton/EnumSingleTon.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/singleton/HungerSingleTon.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/singleton/HungerSingleTon.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/singleton/LazySingleTon.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/singleton/LazySingleTon.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/singleton/MultiLazySingleTon.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/singleton/MultiLazySingleTon.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/singleton/StaticClassSingleTon$StaticClassSingleTonHolder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/singleton/StaticClassSingleTon$StaticClassSingleTonHolder.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/singleton/StaticClassSingleTon.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/singleton/StaticClassSingleTon.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/strategy/PlaneStrategy.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/strategy/PlaneStrategy.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/strategy/Strategy.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/strategy/Strategy.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/strategy/StrategyContext.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/strategy/StrategyContext.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/strategy/TestStrategy.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/strategy/TestStrategy.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/designPattern/strategy/WalkStrategy.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/designPattern/strategy/WalkStrategy.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/generic/GenericClass$Box.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/generic/GenericClass$Box.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/generic/GenericClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/generic/GenericClass.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/generic/GenericFunction.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/generic/GenericFunction.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/generic/GenericInterface.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/generic/GenericInterface.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/generic/GenericSpecial$Box1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/generic/GenericSpecial$Box1.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/generic/GenericSpecial.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/generic/GenericSpecial.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/generic/InterfaceTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/generic/InterfaceTest.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/inject/Apple.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/inject/Apple.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/inject/FruitColor$Color.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/inject/FruitColor$Color.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/inject/FruitColor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/inject/FruitColor.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/inject/FruitName.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/inject/FruitName.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/inject/FruitProvider.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/inject/FruitProvider.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/inject/MainClient.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/inject/MainClient.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/reflect/TestReflect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/reflect/TestReflect.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/reflect/UserManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/reflect/UserManager.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/java/reflect/UserManagerImpl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/java/reflect/UserManagerImpl.class -------------------------------------------------------------------------------- /JavaStudy/bin/com/webcrawler/simple/Test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/com/webcrawler/simple/Test.class -------------------------------------------------------------------------------- /JavaStudy/bin/commons-lang.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/bin/commons-lang.jar -------------------------------------------------------------------------------- /JavaStudy/src/HelloWorld.java: -------------------------------------------------------------------------------- 1 | import com.algorithm.sort.ArrayUtils; 2 | /** 3 | * 4 | * @ClassName: HelloWorld 5 | * 用来测试一些小问题 6 | * @author wangzekeng 7 | * @date 2016年12月9日 上午10:10:48 8 | * 9 | */ 10 | 11 | public class HelloWorld { 12 | 13 | public static void main(String[] args) 14 | { 15 | int a [] = {1,2,3,4}; 16 | int b [] ={8,7,6,3}; 17 | ArrayUtils.changeIndex(a, 0, 1); 18 | ArrayUtils.printArray(a); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /JavaStudy/src/MapTest.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | import java.util.HashMap; 4 | 5 | public class MapTest { 6 | public MapTest(){ 7 | HashMap sensitiveWordMap = new HashMap(100); //初始化敏感词容器,减少扩容操作 8 | HashMap nowMap = sensitiveWordMap; 9 | HashMap newWorMap = new HashMap(); 10 | newWorMap.put("isEnd", "0"); //不是最后一个 11 | nowMap.put("中", newWorMap); 12 | // nowMap = newWorMap; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /JavaStudy/src/ThreadLocalDemo.java: -------------------------------------------------------------------------------- 1 | import java.util.Random; 2 | import java.util.concurrent.ExecutorService; 3 | import java.util.concurrent.Executors; 4 | import java.util.concurrent.TimeUnit; 5 | 6 | public class ThreadLocalDemo { 7 | static class ThreadLocalVariableHolder { 8 | private static ThreadLocal value = new ThreadLocal() { 9 | private Random random = new Random(); 10 | 11 | protected synchronized Integer initialValue() { 12 | return random.nextInt(10000); 13 | } 14 | }; 15 | 16 | public static void increment() { 17 | value.set(value.get() + 1); 18 | } 19 | 20 | public static int get() { 21 | return value.get(); 22 | } 23 | } 24 | 25 | static class Accessor implements Runnable { 26 | private final int id; 27 | 28 | public Accessor(int id) { 29 | this.id = id; 30 | } 31 | 32 | @Override 33 | public void run() { 34 | while (!Thread.currentThread().isInterrupted()) { 35 | ThreadLocalVariableHolder.increment(); 36 | System.out.println(this); 37 | Thread.yield(); 38 | } 39 | } 40 | 41 | @Override 42 | public String toString() { 43 | return "#" + id + ": " + ThreadLocalVariableHolder.get(); 44 | } 45 | 46 | } 47 | 48 | public static void main(String[] args) { 49 | ExecutorService executorService = Executors.newCachedThreadPool(); 50 | for (int i = 0; i < 5; i++) { 51 | executorService.execute(new Accessor(i)); 52 | } 53 | try { 54 | TimeUnit.MICROSECONDS.sleep(1); 55 | } catch (InterruptedException e) { 56 | e.printStackTrace(); 57 | } 58 | executorService.shutdownNow(); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/leetcode/KMP.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.leetcode; 2 | 3 | public class KMP { 4 | public int getIndex(String text,String module){ 5 | //next 6 | int[] next = new int[module.length()]; 7 | next[0] = -1; 8 | for(int i = 1;i=0){ 11 | j = next[j]; 12 | 13 | } 14 | if(module.charAt(i) == module.charAt(j+1)){ 15 | next[i] = j+1; 16 | }else{ 17 | next[i] = -1; 18 | } 19 | } 20 | for(int x : next){ 21 | System.out.println("next:"+ x + " "); 22 | } 23 | 24 | 25 | //find 26 | int i =0; 27 | int j =0; 28 | while(i=0){ 11 | j = next[j]; 12 | } 13 | if(s.charAt(i) == s.charAt(j+1)){ 14 | next[i] = j+1; 15 | }else{ 16 | next[i] = -1; 17 | } 18 | } 19 | 20 | for(int x : next){ 21 | System.out.println("next:" + x); 22 | } 23 | 24 | //find 25 | int i=0,j=0; 26 | while(i=0){ 37 | if(s.charAt(i)==p.charAt(x) || p.charAt(x)=='.'){ 38 | i++; 39 | j++; 40 | break; 41 | }else if(p.charAt(x) == '*'){ 42 | x--; 43 | }else{//不匹配跳下一个next 44 | if(i == 0){ 45 | j++; 46 | }else{ 47 | i = next[i-1] +1; 48 | } 49 | break; 50 | } 51 | } 52 | 53 | }else{ 54 | if(i == 0){ 55 | j++; 56 | }else{ 57 | i = next[i-1] +1; 58 | } 59 | } 60 | } 61 | } 62 | 63 | return i == s.length() ? true : false; 64 | } 65 | public static void main(String[] args) { 66 | Sub10_RegularExpressionMatching sub = new Sub10_RegularExpressionMatching(); 67 | if(sub.isMatch("aaa", "aa")){ 68 | System.out.println("is true"); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/leetcode/Sub1_TwoSum.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.leetcode; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | /** 7 | *Given an array of integers, 8 | *return indices of the two numbers such that they add up to a specific target. 9 | *You may assume that each input would have exactly one solution, 10 | *and you may not use the same element twice. 11 | * 12 | * 13 | * @ClassName: TwoSum 14 | * @Description: TODO 15 | * @author wangzekeng 16 | * @date 2017年10月16日 上午11:23:12 17 | * 18 | */ 19 | public class Sub1_TwoSum { 20 | /** 21 | * 暴力方法,时间复杂度为o(n),空间复杂度o(1) 22 | * @param nums 23 | * @param target 24 | * @return 25 | */ 26 | public int[] twoSum(int[] nums, int target) { 27 | for(int i = 0;i maps = new HashMap(); 48 | for(int i= 0;ilen2){ 21 | return findKth(arr2,arr1,start2,start1,len2,len1,k); 22 | } 23 | if(len1==0){ 24 | return arr2[start2 + k - 1]; 25 | } 26 | if(k==1){ 27 | return Math.min(arr1[start1],arr2[start2]); 28 | } 29 | int p1 = Math.min(k/2,len1) ; 30 | int p2 = k - p1; 31 | if(arr1[start1 + p1-1]arr2[start2 + p2-1]){ 34 | return findKth(arr1,arr2,start1,start2 + p2,len1,len2-p2,k-p2); 35 | } else { 36 | return arr1[start1 + p1-1]; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/leetcode/Sub6_ZigZagConversion.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.leetcode; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class Sub6_ZigZagConversion { 7 | public String convert(String s, int numRows) { 8 | if(numRows == 1){ 9 | return s; 10 | } 11 | int key = 1; 12 | int add = 1; 13 | StringBuffer result = new StringBuffer(""); 14 | Map map = new HashMap(); 15 | StringBuffer str ; 16 | for(int i = 0 ;i< s.length(); i++){ 17 | if(map.containsKey(key)){ 18 | str = map.get(key).append(s.charAt(i)); 19 | }else{ 20 | str =new StringBuffer(""+s.charAt(i)); 21 | } 22 | map.put(key,str); 23 | key = key + add; 24 | if(key == 1){ 25 | add = 1; 26 | } 27 | if(key == numRows){ 28 | add = -1; 29 | } 30 | } 31 | for(int i = 1;i<=numRows;i++){ 32 | if(map.get(i)!=null) 33 | result.append(map.get(i)); 34 | } 35 | return result.toString(); 36 | } 37 | 38 | public static void main(String[] args) { 39 | Sub6_ZigZagConversion sub = new Sub6_ZigZagConversion(); 40 | System.out.println(sub.convert("PAYPALISHIRING", 3)); 41 | System.out.println(sub.convert("A", 2)); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/leetcode/Sub7_ReverseInteger.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.leetcode; 2 | 3 | public class Sub7_ReverseInteger { 4 | public int reverse(int x) { 5 | if(x > Integer.MAX_VALUE || x=0;i--){ 11 | stringBuffer.append(str.charAt(i)); 12 | } 13 | if(x>=0){ 14 | try{ 15 | return Integer.valueOf(stringBuffer.toString()); 16 | }catch(Exception e ){ 17 | return 0; 18 | } 19 | 20 | }else{ 21 | try{ 22 | return -Integer.valueOf(stringBuffer.toString()); 23 | }catch(Exception e ){ 24 | return 0; 25 | } 26 | } 27 | } 28 | public static void main(String[] args) { 29 | Sub7_ReverseInteger sub = new Sub7_ReverseInteger(); 30 | System.out.println(sub.reverse(234)); 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/leetcode/Sub8_StringtoInteger.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.leetcode; 2 | 3 | public class Sub8_StringtoInteger { 4 | public int myAtoi(String str) { 5 | str = str.trim(); 6 | int pre = 1; 7 | int index = 0; 8 | int preNum = 0; 9 | if (str == null || str.equals("")) { 10 | return 0; 11 | } 12 | long result = 0; 13 | if (str.charAt(index) == '-') { 14 | pre = -1; 15 | preNum++; 16 | index++; 17 | } else { 18 | if (str.charAt(index) == '+') { 19 | pre = 1; 20 | preNum++; 21 | index++; 22 | } else { 23 | if (str.charAt(index) > '9' || str.charAt(index) < '0') 24 | return 0; 25 | } 26 | } 27 | 28 | if (index >= str.length() || preNum > 1) { 29 | return 0; 30 | } 31 | 32 | for (int i = index; i < str.length(); i++) { 33 | if (str.charAt(i) >= '0' && str.charAt(i) <= '9') { 34 | if(i>12){ 35 | result = 2147483648L; 36 | break; 37 | } 38 | result = result * 10 + str.charAt(i) - '0'; 39 | } else { 40 | break; 41 | } 42 | 43 | } 44 | 45 | if (result >= 2147483647 && pre == 1) { 46 | return Integer.MAX_VALUE; 47 | } 48 | if (result >= 2147483648L && pre == -1) { 49 | return Integer.MIN_VALUE; 50 | } 51 | result = result * pre; 52 | return (int) result; 53 | } 54 | 55 | public static void main(String[] args) { 56 | Sub8_StringtoInteger sub = new Sub8_StringtoInteger(); 57 | // System.out.println(Integer.valueOf(" -0012a42")); 58 | System.out.println(sub.myAtoi("1111")); 59 | System.out.println(sub.myAtoi("+-2")); 60 | System.out.println(sub.myAtoi("+")); 61 | System.out.println(sub.myAtoi("2147483647")); 62 | int i = 2147483647; 63 | i++; 64 | System.out.println(Integer.MAX_VALUE); 65 | System.out.println(Integer.MIN_VALUE); 66 | System.out.println(sub.myAtoi("2147483648")); 67 | System.out.println(sub.myAtoi("9223372036854775809")); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/leetcode/Sub9_PalindromeNumber.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.leetcode; 2 | 3 | public class Sub9_PalindromeNumber { 4 | //判断是数字 5 | public boolean isPalindrome(int x) { 6 | if(x<0 || (x % 10 == 0 && x !=0)){ 7 | return false; 8 | } 9 | int reservedNum = 0; 10 | while(x > reservedNum){ 11 | reservedNum = reservedNum * 10 + x % 10; 12 | x /= 10; 13 | } 14 | 15 | return (x == reservedNum || x == reservedNum/10); 16 | 17 | } 18 | public static void main(String[] args) { 19 | Sub9_PalindromeNumber sub = new Sub9_PalindromeNumber(); 20 | int x = 10; 21 | if(sub.isPalindrome(x)){ 22 | System.out.println(x + " is a PalindromeNumber"); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/BFS.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class BFS { 6 | public class TreeNode { 7 | int val = 0; 8 | TreeNode left = null; 9 | TreeNode right = null; 10 | 11 | public TreeNode(int val) { 12 | this.val = val; 13 | 14 | } 15 | 16 | } 17 | 18 | public ArrayList PrintFromTopToBottom(TreeNode root) { 19 | return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/Fibonacci.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | 3 | import javax.print.attribute.standard.Finishings; 4 | 5 | /** 6 | * 7 | * @ClassName: Fibonacci 8 | * 题目:找出斐波纳契数列第N项 9 | * 10 | * 思路:递归会消耗内存,非递归消耗空间 11 | * @author wangzekeng 12 | * @date 2016年12月21日 下午3:30:03 13 | * 14 | */ 15 | public class Fibonacci { 16 | public static void main(String[] args) { 17 | Fibonacci fibonacci = new Fibonacci(); 18 | System.out.println(fibonacci.Fibonacci2(5)); 19 | } 20 | 21 | //递归方法,大量计算,内存溢出 22 | public int Fibonacci(int n){ 23 | if(n<=0){ 24 | return 0; 25 | } 26 | if(n == 1){ 27 | return 1; 28 | } 29 | else{ 30 | return Fibonacci(n-1)+Fibonacci(n-2); 31 | } 32 | 33 | } 34 | 35 | //非递归方法 36 | public int Fibonacci2(int n){ 37 | if(n<=0){ 38 | return 0; 39 | } 40 | if(n<=2){ 41 | return 1; 42 | }else{ 43 | int x=1 ,y=1,z = 2; 44 | for(int i = 3;i<=n;i++){ 45 | z = x +y; 46 | x = y; 47 | y = z; 48 | } 49 | return z; 50 | } 51 | 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/FindKthToTail.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | 3 | /** 4 | * 5 | * @ClassName: FindKthToTail 6 | * 题目:输入一个链表,输出该链表中倒数第k个结点。 7 | * 8 | * 思路:用两个节点只需遍历一次 9 | * @author wangzekeng 10 | * @date 2016年12月22日 下午3:22:45 11 | * 12 | */ 13 | class ListNode { 14 | int val; 15 | ListNode next = null; 16 | ListNode(int val) { 17 | this.val = val; 18 | } 19 | } 20 | 21 | public class FindKthToTail { 22 | 23 | public ListNode FindKthToTail(ListNode head, int k) { 24 | if(head==null || k <=0){ 25 | return null; 26 | } 27 | ListNode i=head,j=head; 28 | for(int x = 1;x> lists = new ArrayList>(); 19 | ArrayList list = new ArrayList(); 20 | public class TreeNode { 21 | int val = 0; 22 | TreeNode left = null; 23 | TreeNode right = null; 24 | 25 | public TreeNode(int val) { 26 | this.val = val; 27 | 28 | } 29 | 30 | } 31 | public ArrayList> FindPath(TreeNode root,int target) { 32 | if(root == null){ 33 | return lists; 34 | }//终止条件 35 | list.add(root.val); 36 | if(target == root.val && root.left == null && root.right == null){ 37 | lists.add(new ArrayList(list)); 38 | } 39 | if(target > root.val){ 40 | int tmp = target-root.val; 41 | if(root.left !=null){ 42 | FindPath(root.left, tmp); 43 | } 44 | if(root.right != null){ 45 | FindPath(root.right, tmp); 46 | } 47 | } 48 | list.remove(list.size()-1);//找到后都要回溯 49 | return lists; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/HasSubtree.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | 3 | /** 4 | * 5 | * @ClassName: HasSubtree 6 | * 题目:输入两棵二叉树A,B,判断B是不是A的子结构。(ps:我们约定空树不是任意一个树的子结构) 7 | * 8 | * 思路:利用递归的思想。由于需要先判断是否为空的情况,需要另外用一个函数 9 | * 如果根节点相同则递归调用递归,如果根节点不相同,则判断tree1的左子树和tree2是否相同, 10 | * 再判断右子树和tree2是否相同 11 | * 注意结束条件 12 | * @author wangzekeng 13 | * @date 2016年12月23日 上午11:14:01 14 | * 15 | */ 16 | public class HasSubtree { 17 | 18 | public class TreeNode { 19 | int val = 0; 20 | TreeNode left = null; 21 | TreeNode right = null; 22 | 23 | public TreeNode(int val) { 24 | this.val = val; 25 | } 26 | } 27 | //全部过一遍,简单 28 | public boolean HasSubtree(TreeNode root1, TreeNode root2) { 29 | if(root1 == null || root2 == null){ 30 | return false; 31 | }else{ 32 | return isSubTree(root1, root2) || 33 | HasSubtree(root1.left, root2) || 34 | HasSubtree(root1.right, root2); 35 | } 36 | } 37 | 38 | //剪掉不必要的查找 39 | public boolean HasSubtree2(TreeNode root1, TreeNode root2) { 40 | boolean result = false; 41 | if(root1 != null && root2 != null){ 42 | if(root1.val == root2.val){ 43 | result = isSubTree(root1,root2); 44 | } 45 | if(!result){result = HasSubtree2(root1.left, root2);} 46 | if(!result){result = HasSubtree2(root1.right, root2);} 47 | } 48 | return result; 49 | } 50 | 51 | public boolean isSubTree(TreeNode root1, TreeNode root2) { 52 | if(root2 == null) return true; 53 | if(root1 == null) return false; 54 | if(root1.val != root2.val) return false; 55 | return isSubTree(root1.left, root2.left) && isSubTree(root1.right, root2.right); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/JumpFloor.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | /** 3 | * 4 | * @ClassName: JumpFloor 5 | * 题目:一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法。 6 | * 7 | * 思路:变形的斐波纳契数列 8 | * @author wangzekeng 9 | * @date 2016年12月21日 下午4:52:36 10 | * 11 | */ 12 | public class JumpFloor { 13 | 14 | public static void main(String[] args) { 15 | System.out.println((new JumpFloor()).JumpFloor(4)); 16 | 17 | } 18 | //非递归方法 19 | public int JumpFloor(int target) { 20 | if(target<=2){ 21 | return target; 22 | }else{ 23 | int x=1 ,y=2,z = 3; 24 | for(int i = 3;i<=target;i++){ 25 | z = x +y; 26 | x = y; 27 | y = z; 28 | } 29 | return z; 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/JumpFloorII.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | /** 3 | * 4 | * @ClassName: JumpFloorII 5 | * 题目:一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。 6 | * 7 | * 思路:斐波纳契数列扩展,找出规律即可 8 | * @author wangzekeng 9 | * @date 2016年12月21日 下午5:13:51 10 | * 11 | */ 12 | public class JumpFloorII { 13 | 14 | public static void main(String[] args) { 15 | System.out.println((new JumpFloorII()).JumpFloor2(4)); 16 | 17 | } 18 | 19 | public int JumpFloor(int target) { 20 | if (target == 1) { 21 | return 1; 22 | } else { 23 | int n = 1, result = 1; 24 | while (n < target) { 25 | result = result * 2; 26 | n++; 27 | } 28 | return result; 29 | } 30 | } 31 | 32 | //位运算速度更快 33 | public int JumpFloor2(int target) { 34 | int result = 1; 35 | return result<<(target-1);//<<相当于乘与2 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/MinNumberInRotateArray.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | /** 3 | * 4 | * @ClassName: MinNumberInRotateArray 5 | * 题目: 6 | 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 7 | 输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。 8 | 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 9 | NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。 10 | * 11 | * 12 | * 思路:二分法变形 13 | * 14 | * 15 | * 16 | * @author wangzekeng 17 | * @date 2016年12月21日 下午3:27:53 18 | * 19 | */ 20 | public class MinNumberInRotateArray { 21 | public static void main(String[] args) { 22 | int [] array = {3,4,5,1,2}; 23 | MinNumberInRotateArray solution = new MinNumberInRotateArray(); 24 | System.out.println(solution.minNumberInRotateArray(array)); 25 | } 26 | 27 | public int minNumberInRotateArray(int [] array) { 28 | int low = 0; 29 | int high = array.length-1; 30 | while(low < high){ 31 | int mid = low+ (high-low)/2;//中间或者较小的那个数 32 | if(array[mid]>array[high]){ 33 | low = mid + 1; 34 | }else if(array[mid]==array[high]){ 35 | high = high -1; 36 | }else{ 37 | high = mid; 38 | } 39 | 40 | } 41 | return array[low]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/MirrorTree.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | import java.util.Stack; 3 | /** 4 | * 5 | * @ClassName: MirrorTree 6 | * 题目:操作给定的二叉树,将其变换为源二叉树的镜像。 7 | * 8 | * 思路:递归 9 | * @author wangzekeng 10 | * @date 2016年12月23日 下午5:21:03 11 | * 12 | */ 13 | public class MirrorTree { 14 | public class TreeNode { 15 | int val = 0; 16 | TreeNode left = null; 17 | TreeNode right = null; 18 | 19 | public TreeNode(int val) { 20 | this.val = val; 21 | } 22 | } 23 | //递归算法 24 | public void Mirror(TreeNode root) { 25 | if (root == null) { 26 | return; 27 | } 28 | TreeNode temp = root.left; 29 | root.left = root.right; 30 | root.right = temp; 31 | Mirror(root.left); 32 | Mirror(root.right); 33 | } 34 | 35 | 36 | //利用栈来写非递归 37 | public void Mirror2(TreeNode root) { 38 | if(root == null){ 39 | return; 40 | } 41 | Stack stack = new Stack(); 42 | stack.push(root); 43 | while(!stack.isEmpty()){ 44 | TreeNode node = stack.pop(); 45 | if(node.left != null||node.right != null){ 46 | TreeNode temp = node.left; 47 | node.left = node.right; 48 | node.right = temp; 49 | } 50 | if(node.left!=null){ 51 | stack.push(node.left); 52 | } 53 | if(node.right!=null){ 54 | stack.push(node.right); 55 | } 56 | } 57 | } 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/MyStack.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | /** 6 | * 7 | * @ClassName: MyStack 8 | * 题目:栈的模仿 9 | * 10 | * @author wangzekeng 11 | * @date 2016年12月24日 下午2:16:30 12 | * 13 | */ 14 | public class MyStack { 15 | public static void main(String[] args) { 16 | MyStack myStack = new MyStack(); 17 | myStack.push(3); 18 | System.out.println(myStack.min()); 19 | myStack.push(4); 20 | System.out.println(myStack.min()); 21 | myStack.push(2); 22 | System.out.println(myStack.min()); 23 | myStack.pop(); 24 | System.out.println(myStack.min()); 25 | myStack.pop(); 26 | System.out.println(myStack.min()); 27 | myStack.pop(); 28 | System.out.println(myStack.min()); 29 | myStack.pop(); 30 | System.out.println(myStack.min()); 31 | } 32 | private List list = new ArrayList(); 33 | 34 | public void push(int node) { 35 | list.add(node); 36 | } 37 | 38 | public void pop() { 39 | if (!list.isEmpty()) { 40 | list.remove(list.size() - 1); 41 | } 42 | } 43 | 44 | public int top() { 45 | if (list.isEmpty()) { 46 | return 0; 47 | } 48 | return list.get(list.size() - 1); 49 | } 50 | 51 | public int min() { 52 | if (list.isEmpty()) { 53 | return 0; 54 | } 55 | int min = top(); 56 | for (int index : list) { 57 | min = min <= index ? min : index; 58 | } 59 | return min; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/NumberOf1.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | /** 3 | * 4 | * @ClassName: NumberOf1 5 | * 题目:输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。 6 | * 7 | * 思路:位与运算 8 | * @author wangzekeng 9 | * @date 2016年12月21日 下午5:35:31 10 | * 11 | */ 12 | public class NumberOf1 { 13 | 14 | public static void main(String[] args) { 15 | System.out.println(new NumberOf1().NumberOf1(7)); 16 | } 17 | 18 | public int NumberOf1(int n) { 19 | int count = 0; 20 | while (n != 0) { 21 | count++; 22 | n = n & (n - 1);//用&运算不必考虑补码 23 | } 24 | return count; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/Power.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | /** 3 | * 4 | * @ClassName: Power 5 | * 题目:幂运算 6 | * 7 | * 思路:全面考察幂运算,考虑0的情况,负数情况 8 | * @author wangzekeng 9 | * @date 2016年12月22日 下午2:57:17 10 | * 11 | */ 12 | public class Power { 13 | public static void main(String[] args) { 14 | System.out.println(new Power().Power(2.0,2)); 15 | } 16 | 17 | //传统方法,时间复杂度为log(n) 18 | public double Power(double base, int exponent) { 19 | double result = 1; 20 | for(int i = 0;i PrintFromTopToBottom(TreeNode root) { 29 | ArrayList list = new ArrayList(); 30 | if(root==null){ 31 | return list; 32 | } 33 | Queue queue = new LinkedList();//队列的实现是用LinkedList,LinkedList比ArrayList便于插入和删除 34 | queue.offer(root); 35 | while (!queue.isEmpty()) { 36 | TreeNode treeNode = queue.poll(); 37 | if (treeNode.left != null) { 38 | queue.offer(treeNode.left); 39 | } 40 | if (treeNode.right != null) { 41 | queue.offer(treeNode.right); 42 | } 43 | list.add(treeNode.val); 44 | } 45 | return list; 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/PrintListFromTailToHead.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Stack; 5 | /** 6 | * 7 | * @ClassName: PrintListFromTailToHead 8 | * 题目:输入一个链表,从尾到头打印链表每个节点的值。 9 | * 10 | * 思路:利用栈先进后出的特点 11 | * @author wangzekeng 12 | * @date 2016年12月21日 上午10:34:19 13 | * 14 | */ 15 | public class PrintListFromTailToHead { 16 | public class ListNode { 17 | int val; 18 | ListNode next = null; 19 | 20 | ListNode(int val) { 21 | this.val = val; 22 | } 23 | } 24 | public ArrayList printListFromTailToHead1(ListNode listNode) { 25 | Stack stack=new Stack();//创建栈,必须用integer 26 | while(listNode!=null){ 27 | stack.push(listNode.val);//push方法 28 | listNode=listNode.next; 29 | } 30 | 31 | ArrayList list=new ArrayList(); 32 | while(!stack.isEmpty()){ 33 | list.add(stack.pop());//pop方法弹出 34 | } 35 | return list; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/PrintMatrix.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | 3 | import java.util.ArrayList; 4 | /** 5 | * 6 | * @ClassName: PrintMatrix 7 | * 题目:输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字, 8 | * 例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 9 | * 则依次打印出数字1,2,3,4,8,12,16,15,14,13,9,5,6,7,11,10.(由外到内旋转输出) 10 | * 11 | * 思路:按一圈圈输出 12 | * @author wangzekeng 13 | * @date 2016年12月24日 上午11:39:19 14 | * 15 | */ 16 | public class PrintMatrix { 17 | public static void main(String[] args) { 18 | PrintMatrix printMatrix = new PrintMatrix(); 19 | int[][] matrix = { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 }, { 9, 10 } }; 20 | for (int i : printMatrix.printMatrix(matrix)) { 21 | System.out.println(i); 22 | } 23 | } 24 | 25 | public ArrayList printMatrix(int[][] matrix) { 26 | ArrayList list = new ArrayList(); 27 | if (matrix == null) { 28 | return null; 29 | } 30 | int row = matrix.length; 31 | int width = matrix[0].length; 32 | int circle = width <= row ? ((width + 1) / 2) : ((row + 1) / 2);// 这个圈数计算太麻烦了 33 | 34 | for (int i = 0; i < circle; i++) { 35 | for (int j = i; j < width - i; j++) { 36 | list.add(matrix[i][j]); 37 | } 38 | for (int x = i + 1; x < row - i; x++) { 39 | list.add(matrix[x][width - i - 1]); 40 | } 41 | if (row - i - 1 > i) {// 防止单行的情况 42 | for (int z = width - i - 2; z >= i; z--) { 43 | list.add(matrix[row - i - 1][z]); 44 | } 45 | } 46 | if (width - i - 1 > i) {// 防止单列的情况 47 | for (int m = row - i - 2; m > i; m--) { 48 | list.add(matrix[m][i]); 49 | } 50 | } 51 | 52 | } 53 | return list; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/ReOrderArray.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | /** 6 | * 7 | * @ClassName: ReOrderArray 8 | * 题目: 9 | * 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分, 10 | * 所有的偶数位于位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。 11 | * 12 | * @author wangzekeng 13 | * @date 2016年12月22日 下午3:21:58 14 | * 15 | */ 16 | public class ReOrderArray { 17 | public static void main(String[] args) { 18 | ReOrderArray reOrderArray = new ReOrderArray(); 19 | int [] array = {1,2,3,4,5,6}; 20 | reOrderArray.reOrderArray(array); 21 | for(int index : array){ 22 | System.out.println(index); 23 | } 24 | } 25 | //暴力解决,直接创建连个链表 26 | public void reOrderArray(int[] array) { 27 | List list1 = new ArrayList(); 28 | List list2 = new ArrayList(); 29 | for(int index : array){ 30 | if(index % 2 != 0){ 31 | list1.add(index); 32 | }else{ 33 | list2.add(index); 34 | } 35 | } 36 | list1.addAll(list2); 37 | for(int i = 0;i=0 && indexold stack = new Stack(); 21 | stack.push(head); 22 | while (head.next != null) { 23 | head = head.next; 24 | stack.push(head); 25 | } 26 | head = stack.pop(); 27 | while (!stack.isEmpty()) { 28 | head.next = stack.pop(); 29 | } 30 | return head; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/SortedArrayFind.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | /** 3 | * 4 | * @ClassName: SortedArrayFind 5 | * @题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序, 6 | * 每一列都按照从上到下递增的顺序排序。 7 | * 请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 8 | * 9 | * @思路:从左下角向上递减,向右递增 10 | * @author wangzekeng 11 | * @date 2016年12月21日 上午9:45:04 12 | * 13 | */ 14 | public class SortedArrayFind { 15 | public static void main(String[] args) { 16 | SortedArrayFind sortedArrayFind = new SortedArrayFind(); 17 | int [][] array = {{1,2,3},{4,5,6},{7,8,9}}; 18 | if(sortedArrayFind.Find(10, array)){ 19 | System.out.println("true"); 20 | }else{ 21 | System.out.println("false"); 22 | } 23 | } 24 | public boolean Find(int target, int [][] array) { 25 | int height = array.length; //二维的length表示有多少行,不是元素个数 26 | int width = array[0].length; 27 | int i = height-1; 28 | int j = 0; 29 | while(i>=0 && j<=width-1){ 30 | if(target == array[i][j]){ 31 | return true; //有return就已经跳出了 32 | }else if(target stack = new Stack(); 36 | int i = 0; 37 | for(int index : popA){ 38 | if(!stack.isEmpty() && stack.peek() == index){ 39 | stack.pop(); 40 | } 41 | while(i stack1 = new Stack(); 32 | Stack stack2 = new Stack(); 33 | 34 | public void push(int node) { 35 | stack1.push(node); 36 | } 37 | 38 | public int pop() { 39 | if(stack1.isEmpty() && stack2.isEmpty()){ 40 | throw new RuntimeException("队列为空"); 41 | }else{ 42 | if(stack2.isEmpty()){//当输出全部完了才要重新输入,先进的永远先出 43 | while(!stack1.isEmpty()){//一次性将stack1 输入到stack2 44 | stack2.push(stack1.pop()); 45 | } 46 | } 47 | return stack2.pop(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/niukecoder/VerifySquenceOfBST.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.niukecoder; 2 | /** 3 | * 4 | * @ClassName: VerifySquenceOfBST 5 | * 题目:输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历的结果。 6 | * 如果是则输出Yes,否则输出No。假设输入的数组的任意两个数字都互不相同。 7 | * 8 | * 9 | * 思路:有递归和非递归。递归:最后一位元素为根,分为两段,前面一段所有元素都小于根, 10 | * 后面一段所有元素都大于跟。然后递归两段,注意单支问题 11 | * 12 | * @author wangzekeng 13 | * @date 2017年2月20日 上午11:09:44 14 | * 15 | */ 16 | public class VerifySquenceOfBST { 17 | //递归 18 | public boolean VerifySquenceOfBST(int[] sequence) { 19 | int size = sequence.length; 20 | if (size == 0) { 21 | return false; 22 | } else { 23 | return isOrder(sequence, 0, size - 1); 24 | } 25 | } 26 | 27 | public boolean isOrder(int[] sequence, int low, int high) { 28 | if (low == high) { 29 | return true; 30 | } 31 | int mid = low; 32 | while (sequence[mid++] < sequence[high] && mid < high) 33 | ; 34 | int tmp = mid; 35 | while (sequence[tmp++] > sequence[high] && tmp < high) 36 | ; 37 | if (tmp < high) { 38 | return false; 39 | } 40 | if (mid == low || mid == high) { 41 | return isOrder(sequence, low, high - 1); 42 | } else { 43 | return (isOrder(sequence, low, mid - 1) && isOrder(sequence, mid, 44 | high - 1)); 45 | } 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/sort/ArrayUtils.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.sort; 2 | /** 3 | * 4 | * @ClassName: ArrayUtils 5 | * 数组操作工具类,判断数组是否为空,交换数据 6 | * @author wangzekeng 7 | * @date 2016年12月9日 上午10:11:30 8 | * 9 | */ 10 | public class ArrayUtils { 11 | public static void printArray(int [] array){ 12 | for(int x : array){ 13 | System.out.print(" "+x); 14 | } 15 | System.out.print("\n"); 16 | } 17 | public static void changeIndex(int [] array, int index1, int index2){ 18 | array[index1] = array[index1]^array[index2]; 19 | array[index2] = array[index1]^array[index2]; 20 | array[index1] = array[index1]^array[index2]; 21 | } 22 | public static boolean isEmpty(int [] array){ 23 | if(array==null || array.length<=0) 24 | return true; 25 | else 26 | return false; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/sort/BubbleSort.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.sort; 2 | /** 3 | * 4 | * @ClassName: BubbleSort 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2016年12月9日 上午10:14:45 8 | * 9 | */ 10 | 11 | public class BubbleSort { 12 | /* 13 | * 冒泡排序 14 | * 每趟与后面的数一一比较,比较时交换位置 15 | * 时间复杂度: 16 | * 平均,最好,最坏:0(n^2) 17 | * 改进:最好情况是0(n):增加控制循环标志 18 | * 空间复杂度:0(1) 19 | * 稳定性:稳定 20 | */ 21 | public static void main(String arg[]){ 22 | int [] a = {1,2,8,4,3,10}; 23 | BubbleSort.sort(a); 24 | ArrayUtils.printArray(a); 25 | } 26 | public static void sort(int [] array){ 27 | boolean isSort;//判断是否有序 28 | if(ArrayUtils.isEmpty(array)){ 29 | return ; 30 | } 31 | for(int i= 0 ;iarray[j+1]){ 35 | ArrayUtils.changeIndex(array, j, j+1); 36 | isSort = false;//需要交换时则是无序 37 | } 38 | } 39 | if(isSort) 40 | return;//有序时直接结束 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/sort/ChoiceSort.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.sort; 2 | 3 | /* 4 | * 选择排序 5 | * 每趟排序与后面的数一一比较,选出最小数(最大数),交换位置。 6 | * 时间复杂度: 7 | * 最好,平均,最坏:n^2,有序也要遍历一边 8 | * 空间复杂度:0(1) 9 | * 稳定性:不稳定,5 8 5 2 9,当有一个小的在相同的后面时会交换 10 | */ 11 | public class ChoiceSort { 12 | public static void main(String arg[]){ 13 | int [] a = {1,2,8,4,3,10}; 14 | ChoiceSort.sort(a); 15 | ArrayUtils.printArray(a); 16 | } 17 | public static void sort(int [] array){ 18 | if(ArrayUtils.isEmpty(array)){//写排序都应该先判断空的情况 19 | return ; 20 | } 21 | for(int i= 0 ;i0;i--){ 26 | ArrayUtils.changeIndex(array, 0, i);//每次将堆顶元素和无序区最后一个元素交换,即将无序区最大的元素放入有序区 27 | ajustHeap(array, 0, i);//将无序区调整为大顶堆,即选择出最大的元素。 28 | } 29 | } 30 | /* 31 | * 初始化大根堆 32 | */ 33 | public static void buildMaxHeap(int [] array){ 34 | int size = array.length; 35 | //从最后一个非叶子节点调整到根节点 36 | for(int i = size/2-1;i>=0;i--){//size/2-1为最后一个非叶子节点下标(因为堆是一种满二叉树,由满二叉树性质可知) 37 | ajustHeap(array, i, size); 38 | } 39 | } 40 | /* 41 | * 调整堆 42 | */ 43 | public static void ajustHeap(int [] array,int i,int size){ 44 | if(iarray[max]){ 50 | max = left; 51 | } 52 | if(rightarray[max]){ 53 | max = right; 54 | } 55 | if(max!=i){ 56 | ArrayUtils.changeIndex(array, max, i);//交换 57 | ajustHeap(array, max, size);//有交换会破坏大根堆性质,需要重新调整,与max值有关 58 | } 59 | 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/sort/InsertSort.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.sort; 2 | 3 | /* 4 | * 插入排序 5 | * 从第二元素开始,每次与前面的元素比较(前面元素以排序),找到他的位置,则将前面的元素往后移动,留出空位给插入元素。 6 | * 时间复杂度: 7 | * 最坏,平均:0(n^2) 8 | * 最好:0(n) 9 | * 空间复杂度:0(1) 10 | * 稳定性:稳定 11 | * 12 | */ 13 | public class InsertSort { 14 | public static void main(String arg[]){ 15 | int [] a = {5,2,8,4,3,10}; 16 | InsertSort.sort(a); 17 | ArrayUtils.printArray(a); 18 | } 19 | public static void sort(int [] array){ 20 | int j; 21 | int currentValue; 22 | for(int i=1;i=0 && array[j]>currentValue ){//当前小则前面元素需要移动 26 | //注意:j>=0条件要放在前面,如果放后面可能出现j<0导致array[j]越界 27 | array[j+1]=array[j]; 28 | j--; 29 | 30 | } 31 | array[j+1] = currentValue;//注意上面j--减多了一位要加回来 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /JavaStudy/src/com/algorithm/sort/MergeSort.java: -------------------------------------------------------------------------------- 1 | package com.algorithm.sort; 2 | 3 | /* 4 | * 归并排序 5 | * 利用递归的思想:直接取中间位分成两段,再递归排序 6 | * 时间复杂度: 7 | * 平均,最好:0(nlogn) 8 | * 最坏:0(nlogn) 9 | * 空间复杂度: 10 | * 0(n):需要一个存储临时变量的数组 11 | * 稳定性:稳定 12 | */ 13 | public class MergeSort { 14 | public static void main(String arg[]){ 15 | int [] a = {10,5,1,9,2,25}; 16 | MergeSort.sort(a, 0, a.length-1); 17 | for(int x : a){ 18 | System.out.print(" " + x); 19 | } 20 | } 21 | public static void sort(int[] array,int left ,int right){ 22 | if(ArrayUtils.isEmpty(array)){ 23 | return; 24 | } 25 | if(leftp){ 38 | right--;//每趟需要找到比标志位小的数 39 | } 40 | array[left] = array[right];//赋给左边 41 | while(left0;gap /= 2){//步长再递减 21 | for(i=0;i=0 && array[key]>temp ){ 28 | array[key+gap]=array[key]; 29 | key-=gap; 30 | } 31 | array[key+gap] =temp; 32 | 33 | } 34 | } 35 | } 36 | } 37 | } 38 | public static void sort2(int a[], int n) 39 | { 40 | int j, gap; 41 | 42 | for (gap = n / 2; gap > 0; gap /= 2) 43 | for (j = gap; j < n; j++)//从数组第gap个元素开始 44 | if (a[j] < a[j - gap])//每个元素与自己组内的数据进行直接插入排序 45 | { 46 | int temp = a[j]; 47 | int k = j - gap; 48 | while (k >= 0 && a[k] > temp) 49 | { 50 | a[k + gap] = a[k]; 51 | k -= gap; 52 | } 53 | a[k + gap] = temp; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/abtractFactory/AbtractGenerator.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.abtractFactory; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | /** 6 | * 7 | * 结合反射的工厂类 8 | * 9 | * 结合反射无需写switch,新增加产品也无需修改此类,符合开闭原则 10 | * 同时产品构造函数可以私有化,防止客户通过构造函数构造 11 | * 12 | * @ClassName: ReflectPhoneGenerator 13 | * @Description: TODO 14 | * @author wangzekeng 15 | * @date 2017年9月14日 上午10:34:41 16 | * 17 | */ 18 | public class AbtractGenerator implements IAbtractGenerator{ 19 | 20 | private Map phoneMap = new HashMap();//缓存 21 | private Map padMap = new HashMap(); 22 | @Override 23 | public T generatePhone(Class cls) throws Exception { 24 | // TODO Auto-generated method stub 25 | T phone = null; 26 | String phoneName = cls.getSimpleName(); 27 | if(phoneMap.containsKey(phoneName)){ 28 | 29 | phone = (T)phoneMap.get(phoneName); 30 | }else{ 31 | cls.getDeclaredConstructor().setAccessible(true); //修改访问权限 32 | phone = cls.newInstance(); 33 | phoneMap.put(phoneName, phone); 34 | } 35 | return phone; 36 | } 37 | 38 | 39 | @Override 40 | public T generatePad(Class cls) throws Exception { 41 | // TODO Auto-generated method stub 42 | T pad = null; 43 | String phoneName = cls.getSimpleName(); 44 | if(phoneMap.containsKey(phoneName)){ 45 | 46 | pad = (T)padMap.get(phoneName); 47 | }else{ 48 | cls.getDeclaredConstructor().setAccessible(true); //修改访问权限 49 | pad = cls.newInstance(); 50 | padMap.put(phoneName, pad); 51 | } 52 | return pad; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/abtractFactory/AndroidPad.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.abtractFactory; 2 | 3 | public class AndroidPad implements IPad{ 4 | protected AndroidPad(){}; 5 | @Override 6 | public void getOS() { 7 | // TODO Auto-generated method stub 8 | System.out.println("i am android pad"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/abtractFactory/AndroidPhone.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.abtractFactory; 2 | 3 | public class AndroidPhone implements IPhone{ 4 | protected AndroidPhone(){}; 5 | @Override 6 | public void getOS() { 7 | // TODO Auto-generated method stub 8 | System.out.println("i am android phone"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/abtractFactory/IAbtractGenerator.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.abtractFactory; 2 | 3 | public interface IAbtractGenerator { 4 | public T generatePhone(Class cls)throws Exception; 5 | 6 | 7 | public T generatePad(Class cls)throws Exception; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/abtractFactory/IPad.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.abtractFactory; 2 | 3 | public interface IPad { 4 | public void getOS(); 5 | } 6 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/abtractFactory/IPhone.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.abtractFactory; 2 | 3 | public interface IPhone { 4 | public void getOS(); 5 | } 6 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/abtractFactory/IosPad.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.abtractFactory; 2 | 3 | public class IosPad implements IPhone{ 4 | protected IosPad(){}; 5 | @Override 6 | public void getOS() { 7 | // TODO Auto-generated method stub 8 | System.out.println("i am ios pad"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/abtractFactory/IosPhone.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.abtractFactory; 2 | 3 | public class IosPhone implements IPhone{ 4 | protected IosPhone(){}; 5 | @Override 6 | public void getOS() { 7 | // TODO Auto-generated method stub 8 | System.out.println("i am ios phone"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/abtractFactory/MainClient.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.abtractFactory; 2 | /** 3 | * 抽象工厂模式 4 | * 5 | * 一个工厂可以生产更多系列 6 | * 7 | * 可以结合反射来解除耦合 8 | * 9 | * @ClassName: IosGenertor 10 | * @Description: TODO 11 | * @author wangzekeng 12 | * @date 2017年9月13日 下午5:50:56 13 | * 14 | */ 15 | public class MainClient { 16 | public static void main(String[] args) { 17 | 18 | 19 | //通过反射 20 | AbtractGenerator generator = new AbtractGenerator(); 21 | try { 22 | generator.generatePhone(AndroidPhone.class).getOS(); 23 | } catch (Exception e) { 24 | System.out.println("可以捕获异常"); 25 | } 26 | 27 | try { 28 | generator.generatePad(AndroidPad.class).getOS(); 29 | } catch (Exception e) { 30 | System.out.println("可以捕获异常"); 31 | } 32 | 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/adapter/Adaptee.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.adapter; 2 | /** 3 | * 被适配类 4 | * @ClassName: Adaptee 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月10日 上午11:28:19 8 | * 9 | */ 10 | public class Adaptee { 11 | public void specialRequest(){ 12 | System.out.println("原系统的特殊功能。。。。"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/adapter/Client.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.adapter; 2 | /** 3 | * 适配模式 4 | * 5 | * 原本由于接口不兼容而不能一起工作的那些类可以在一起工作 6 | * 类似插头转换器的功能 7 | * @ClassName: Client 8 | * @Description: TODO 9 | * @author wangzekeng 10 | * @date 2017年10月10日 下午3:14:15 11 | * 12 | */ 13 | public class Client { 14 | public static void main(String[] args) { 15 | 16 | //适配器1:继承 17 | InheritAdapter adapter = new InheritAdapter(); 18 | adapter.request(); 19 | 20 | 21 | //适配器2:直接封装 22 | WrapAdapter wrapAdapter = new WrapAdapter(new Adaptee()); 23 | wrapAdapter.request(); 24 | } 25 | } -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/adapter/InheritAdapter.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.adapter; 2 | 3 | 4 | /** 5 | * 适配器 6 | * 继承原系统类,再进行封装 7 | * @ClassName: Adapter 8 | * @Description: TODO 9 | * @author wangzekeng 10 | * @date 2017年10月10日 上午11:31:15 11 | * 12 | */ 13 | public class InheritAdapter extends Adaptee implements Target{ 14 | 15 | @Override 16 | public void request() { 17 | // TODO Auto-generated method stub 18 | super.specialRequest(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/adapter/Target.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.adapter; 2 | /** 3 | * 目标接口 4 | * @ClassName: Target 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月10日 上午11:31:31 8 | * 9 | */ 10 | public interface Target { 11 | public void request(); 12 | } 13 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/adapter/WrapAdapter.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.adapter; 2 | /** 3 | * 适配器 4 | * 直接封装一个原系统类作为成员变量 5 | * @ClassName: WrapAdapter 6 | * @Description: TODO 7 | * @author wangzekeng 8 | * @date 2017年10月10日 上午11:49:30 9 | * 10 | */ 11 | public class WrapAdapter implements Target{ 12 | private Adaptee adaptee; 13 | 14 | public WrapAdapter(Adaptee adaptee) { 15 | this.adaptee = adaptee; 16 | } 17 | @Override 18 | public void request() { 19 | // TODO Auto-generated method stub 20 | adaptee.specialRequest(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/builder/TestBuilder.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.builder; 2 | 3 | 4 | public class TestBuilder { 5 | public static void main(String[] args) { 6 | Person.Builder builder = new Person.Builder(); 7 | Person person = builder.name("张三").age(11).height(14).weight(12).create(); 8 | person.setAge(1111); 9 | System.out.println(person.toString()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/command/ChangeChannelCommand.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.command; 2 | /** 3 | * 具体命令 4 | * @ClassName: ChangeChannelCommand 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月12日 下午3:45:07 8 | * 9 | */ 10 | public class ChangeChannelCommand implements Command{ 11 | private Tv mTv; 12 | private int channel; 13 | public ChangeChannelCommand(Tv tv,int channel){ 14 | this.mTv = tv; 15 | this.channel = channel; 16 | } 17 | 18 | @Override 19 | public void excute() { 20 | // TODO Auto-generated method stub 21 | mTv.changeChannel(channel); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/command/Client.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.command; 2 | /** 3 | * 命令模式 4 | * @ClassName: Client 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月12日 下午3:46:27 8 | * 9 | */ 10 | public class Client { 11 | public static void main(String[] args) { 12 | Tv tv = new Tv(); 13 | TurnOffCommand turnOffCommand = new TurnOffCommand(tv); 14 | TurnOnCommand turnOnCommand = new TurnOnCommand(tv); 15 | ChangeChannelCommand changeChannelCommand = new ChangeChannelCommand(tv,2); 16 | Invoke invoke = new Invoke(turnOffCommand, turnOnCommand, changeChannelCommand); 17 | invoke.turnOn(); 18 | invoke.changeChannel(); 19 | invoke.turnOff(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/command/Command.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.command; 2 | /** 3 | * 命令接口 4 | * @ClassName: Command 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月12日 下午3:44:18 8 | * 9 | */ 10 | public interface Command { 11 | public void excute(); 12 | } 13 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/command/Invoke.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.command; 2 | /** 3 | * 命令的执行者 4 | * @ClassName: Invoke 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月12日 下午3:46:14 8 | * 9 | */ 10 | public class Invoke { 11 | private TurnOffCommand turnOffCommand; 12 | private TurnOnCommand turnOnCommand; 13 | private ChangeChannelCommand changeChannelCommand; 14 | public Invoke(TurnOffCommand turnOffCommand,TurnOnCommand turnOnCommand,ChangeChannelCommand changeChannelCommand){ 15 | this.turnOnCommand = turnOnCommand; 16 | this.turnOffCommand = turnOffCommand; 17 | this.changeChannelCommand = changeChannelCommand; 18 | } 19 | 20 | public void turnOff(){ 21 | turnOffCommand.excute(); 22 | } 23 | 24 | public void turnOn(){ 25 | turnOnCommand.excute(); 26 | } 27 | 28 | public void changeChannel(){ 29 | changeChannelCommand.excute(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/command/TurnOffCommand.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.command; 2 | /** 3 | * 具体命名 4 | * @ClassName: TurnOffCommand 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月12日 下午3:44:37 8 | * 9 | */ 10 | public class TurnOffCommand implements Command{ 11 | private Tv mTv; 12 | public TurnOffCommand(Tv tv){ 13 | this.mTv = tv; 14 | } 15 | 16 | @Override 17 | public void excute() { 18 | // TODO Auto-generated method stub 19 | mTv.turnOff(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/command/TurnOnCommand.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.command; 2 | /** 3 | * 具体命令 4 | * @ClassName: TurnOnCommand 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月12日 下午3:44:52 8 | * 9 | */ 10 | public class TurnOnCommand implements Command{ 11 | private Tv mTv; 12 | public TurnOnCommand(Tv tv){ 13 | this.mTv = tv; 14 | } 15 | @Override 16 | public void excute() { 17 | // TODO Auto-generated method stub 18 | mTv.turnOn(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/command/Tv.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.command; 2 | /** 3 | * 命令的接收者 4 | * @ClassName: Tv 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月12日 下午3:45:54 8 | * 9 | */ 10 | public class Tv { 11 | private int channel; 12 | 13 | public void turnOn(){ 14 | System.out.println("tv turn on"); 15 | } 16 | 17 | public void turnOff(){ 18 | System.out.println("tv turn off"); 19 | } 20 | 21 | public void changeChannel(int channel){ 22 | this.channel = channel; 23 | System.out.println("current channel is "+ channel); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/component/BaiYunMarket.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.component; 2 | /** 3 | * 组件,分店 4 | * @ClassName: BaiYunMarket 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月12日 上午10:10:43 8 | * 9 | */ 10 | public class BaiYunMarket extends Market{ 11 | 12 | public BaiYunMarket(String name) { 13 | this.name = name; 14 | } 15 | 16 | @Override 17 | public void add(Market m) { 18 | // TODO Auto-generated method stub 19 | 20 | } 21 | 22 | @Override 23 | public void remove(Market m) { 24 | // TODO Auto-generated method stub 25 | 26 | } 27 | 28 | @Override 29 | public void pay() { 30 | // TODO Auto-generated method stub 31 | System.out.println(name + "消费了"); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/component/Client.java: -------------------------------------------------------------------------------- 1 | 2 | package com.designPattern.component; 3 | 4 | import javax.swing.text.Position.Bias; 5 | /** 6 | * 组合模式 7 | * @ClassName: Client 8 | * @Description: TODO 9 | * @author wangzekeng 10 | * @date 2017年10月12日 上午10:11:57 11 | * 12 | */ 13 | public class Client { 14 | public static void main(String[] args) { 15 | GuangzhouMarket guangzhouMarket = new GuangzhouMarket("广州"); 16 | TianHeMarket tianHeMarket = new TianHeMarket("天河分店"); 17 | BaiYunMarket baiYunMarket = new BaiYunMarket("白云分店"); 18 | guangzhouMarket.add(tianHeMarket); 19 | guangzhouMarket.add(baiYunMarket); 20 | guangzhouMarket.pay(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/component/GuangzhouMarket.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.component; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | /** 6 | * 组件的集合,总店 7 | * @ClassName: GuangzhouMarket 8 | * @Description: TODO 9 | * @author wangzekeng 10 | * @date 2017年10月12日 上午10:11:16 11 | * 12 | */ 13 | public class GuangzhouMarket extends Market{ 14 | 15 | public GuangzhouMarket(String name) { 16 | this.name = name; 17 | } 18 | 19 | List list = new ArrayList(); 20 | @Override 21 | public void add(Market m) { 22 | // TODO Auto-generated method stub 23 | list.add(m); 24 | } 25 | 26 | @Override 27 | public void remove(Market m) { 28 | // TODO Auto-generated method stub 29 | list.remove(m); 30 | } 31 | 32 | @Override 33 | public void pay() { 34 | // TODO Auto-generated method stub 35 | System.out.println(name+"消费了"); 36 | for(Market m : list){ 37 | m.pay(); 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/component/Market.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.component; 2 | 3 | public abstract class Market { 4 | String name; 5 | public abstract void add(Market m); 6 | 7 | public abstract void remove(Market m); 8 | 9 | public abstract void pay(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/component/TianHeMarket.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.component; 2 | /** 3 | * 组件,分店 4 | * @ClassName: TianHeMarket 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月12日 上午10:11:02 8 | * 9 | */ 10 | public class TianHeMarket extends Market { 11 | 12 | public TianHeMarket(String name) { 13 | this.name = name; 14 | } 15 | 16 | @Override 17 | public void add(Market m) { 18 | // TODO Auto-generated method stub 19 | 20 | } 21 | 22 | @Override 23 | public void remove(Market m) { 24 | // TODO Auto-generated method stub 25 | 26 | } 27 | 28 | @Override 29 | public void pay() { 30 | System.out.println(name + "消费了"); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/decorator/Client.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.decorator; 2 | 3 | public class Client { 4 | public static void main(String[] args) { 5 | Human person = new Person(); 6 | Decorator decorator = new ThirdDecorator(new SecondDecorator(new firstDecorator(person))); 7 | decorator.wearClothes(); 8 | decorator.walkToWhere(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/decorator/Decorator.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.decorator; 2 | /** 3 | * 装饰者 4 | * @ClassName: Decorator 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月10日 下午5:34:40 8 | * 9 | */ 10 | public abstract class Decorator implements Human{ 11 | private Human human; 12 | public Decorator(Human human){ 13 | this.human = human; 14 | } 15 | 16 | public void wearClothes(){ 17 | human.wearClothes(); 18 | } 19 | 20 | public void walkToWhere(){ 21 | human.walkToWhere(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/decorator/Human.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.decorator; 2 | /** 3 | * 被装饰接口 4 | * @ClassName: Human 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月10日 下午5:30:20 8 | * 9 | */ 10 | public interface Human { 11 | public void wearClothes(); 12 | 13 | public void walkToWhere(); 14 | } 15 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/decorator/Person.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.decorator; 2 | 3 | public class Person implements Human{ 4 | 5 | @Override 6 | public void wearClothes() { 7 | // TODO Auto-generated method stub 8 | System.out.println("穿什么好?"); 9 | } 10 | 11 | @Override 12 | public void walkToWhere() { 13 | // TODO Auto-generated method stub 14 | System.out.println("去哪里好?"); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/decorator/SecondDecorator.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.decorator; 2 | 3 | 4 | public class SecondDecorator extends Decorator{ 5 | 6 | public SecondDecorator(Human human) { 7 | super(human); 8 | // TODO Auto-generated constructor stub 9 | } 10 | public void findClothes(){ 11 | System.out.println("找到一件t恤"); 12 | } 13 | 14 | 15 | public void findMap(){ 16 | System.out.println("找到一张地图"); 17 | } 18 | @Override 19 | public void walkToWhere() { 20 | // TODO Auto-generated method stub 21 | super.walkToWhere(); 22 | findMap(); 23 | } 24 | 25 | @Override 26 | public void wearClothes() { 27 | // TODO Auto-generated method stub 28 | super.wearClothes(); 29 | findClothes(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/decorator/ThirdDecorator.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.decorator; 2 | 3 | public class ThirdDecorator extends Decorator{ 4 | 5 | public ThirdDecorator(Human human) { 6 | super(human); 7 | // TODO Auto-generated constructor stub 8 | } 9 | 10 | public void wearThirt(){ 11 | System.out.println("穿上t恤"); 12 | } 13 | 14 | public void goPark(){ 15 | System.out.println("去公园"); 16 | } 17 | 18 | @Override 19 | public void walkToWhere() { 20 | // TODO Auto-generated method stub 21 | super.walkToWhere(); 22 | goPark(); 23 | } 24 | 25 | @Override 26 | public void wearClothes() { 27 | // TODO Auto-generated method stub 28 | super.wearClothes(); 29 | wearThirt(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/decorator/firstDecorator.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.decorator; 2 | 3 | public class firstDecorator extends Decorator{ 4 | 5 | public firstDecorator(Human human) { 6 | super(human); 7 | // TODO Auto-generated constructor stub 8 | } 9 | 10 | public void goHome(){ 11 | System.out.println("回家。。。"); 12 | } 13 | 14 | public void lookCloset(){ 15 | System.out.println("去衣柜看看。。。"); 16 | } 17 | @Override 18 | public void walkToWhere() { 19 | // TODO Auto-generated method stub 20 | super.walkToWhere(); 21 | goHome(); 22 | } 23 | 24 | @Override 25 | public void wearClothes() { 26 | // TODO Auto-generated method stub 27 | super.wearClothes(); 28 | lookCloset(); 29 | } 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/facade/ModuleA.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.facade; 2 | /** 3 | * 子模块 4 | * @ClassName: ModuleA 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月11日 上午11:04:12 8 | * 9 | */ 10 | public class ModuleA { 11 | 12 | //外部使用 13 | public void test(){ 14 | System.out.println("ModuleA test..."); 15 | } 16 | 17 | 18 | //内部使用 19 | public void a1(){}; 20 | public void a2(){}; 21 | } 22 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/facade/ModuleB.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.facade; 2 | /** 3 | * 子模块 4 | * @ClassName: ModuleB 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月11日 上午11:05:45 8 | * 9 | */ 10 | public class ModuleB { 11 | //外部使用 12 | public void test(){ 13 | System.out.println("ModuleB test..."); 14 | } 15 | 16 | 17 | //内部使用 18 | public void b1(){}; 19 | public void b2(){}; 20 | } 21 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/facade/ModuleC.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.facade; 2 | /** 3 | * 子模块 4 | * @ClassName: ModuleC 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月11日 上午11:06:16 8 | * 9 | */ 10 | public class ModuleC { 11 | //外部使用 12 | public void test(){ 13 | System.out.println("ModuleC test..."); 14 | } 15 | 16 | 17 | //内部使用 18 | public void c1(){}; 19 | public void c2(){}; 20 | } 21 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/facade/ModuleFacade.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.facade; 2 | /** 3 | * 外观模式 4 | * 5 | * 将子模块集合封装,隐藏内部细节 6 | * @ClassName: ModuleFacade 7 | * @Description: TODO 8 | * @author wangzekeng 9 | * @date 2017年10月11日 上午11:08:50 10 | * 11 | */ 12 | public class ModuleFacade { 13 | private ModuleA moduleA = new ModuleA(); 14 | private ModuleB moduleB = new ModuleB(); 15 | private ModuleC moduleC = new ModuleC(); 16 | public void test(){ 17 | moduleA.test(); 18 | moduleB.test(); 19 | moduleC.test(); 20 | } 21 | 22 | public static void main(String[] args) { 23 | ModuleFacade moduleFacade = new ModuleFacade(); 24 | moduleFacade.test(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/factory/AndroidGenerator.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.factory; 2 | 3 | public class AndroidGenerator implements IGenerator{ 4 | 5 | @Override 6 | public IPhone generatePhone() { 7 | // TODO Auto-generated method stub 8 | return new AndroidPhone(); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/factory/AndroidPhone.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.factory; 2 | 3 | public class AndroidPhone implements IPhone{ 4 | protected AndroidPhone(){}; 5 | @Override 6 | public void getOS() { 7 | // TODO Auto-generated method stub 8 | System.out.println("i am android"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/factory/IGenerator.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.factory; 2 | 3 | public interface IGenerator { 4 | public IPhone generatePhone(); 5 | } 6 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/factory/IPhone.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.factory; 2 | 3 | public interface IPhone { 4 | public void getOS(); 5 | } 6 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/factory/IosGenertor.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.factory; 2 | 3 | public class IosGenertor implements IGenerator{ 4 | 5 | @Override 6 | public IPhone generatePhone() { 7 | // TODO Auto-generated method stub 8 | return new IosPhone(); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/factory/IosPhone.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.factory; 2 | 3 | public class IosPhone implements IPhone{ 4 | protected IosPhone(){}; 5 | @Override 6 | public void getOS() { 7 | // TODO Auto-generated method stub 8 | System.out.println("i am ios"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/factory/MainClient.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.factory; 2 | /** 3 | * 标准工厂模式 4 | * 5 | * 工厂模式降低使用者和产品之间的耦合 6 | * 标准工厂模式符合开闭原则,有新的产品,需要增加产品和对应的工厂,无需修改已有代码 7 | * 标准工厂模式组成:产品抽象类,产品具体类,工厂抽象类,工厂类 8 | * 9 | * 10 | * @ClassName: IosGenertor 11 | * @Description: TODO 12 | * @author wangzekeng 13 | * @date 2017年9月13日 下午5:50:56 14 | * 15 | */ 16 | public class MainClient { 17 | public static void main(String[] args) { 18 | IPhone ios,android; 19 | IGenerator iosGenerator = new IosGenertor(); 20 | ios = iosGenerator.generatePhone(); 21 | ios.getOS(); 22 | IGenerator androidGenerator = new AndroidGenerator(); 23 | android = androidGenerator.generatePhone(); 24 | android.getOS(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/flyweight/Client.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.flyweight; 2 | /** 3 | * 享元模式 4 | * 把对象存储起来,避免相同对象重复创建 5 | * @ClassName: Client 6 | * @Description: TODO 7 | * @author wangzekeng 8 | * @date 2017年10月11日 下午4:41:40 9 | * 10 | */ 11 | public class Client { 12 | public static void main(String[] args) { 13 | FlyweightFactory factory = new FlyweightFactory(); 14 | Flyweight technology = factory.getFlyweight("tech"); 15 | Flyweight designer = factory.getFlyweight("design"); 16 | Flyweight manager = factory.getFlyweight("manager"); 17 | Flyweight designer2 = factory.getFlyweight("design"); 18 | Flyweight designer3 = factory.getFlyweight("design"); 19 | Flyweight designer4 = factory.getFlyweight("design"); 20 | technology.operation(); 21 | designer.operation(); 22 | manager.operation(); 23 | designer2.operation(); 24 | designer3.operation(); 25 | designer4.operation(); 26 | System.out.println(factory.getFlyweightSize()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/flyweight/ConcreteFlyweight.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.flyweight; 2 | 3 | public class ConcreteFlyweight extends Flyweight{ 4 | private String name; 5 | 6 | public ConcreteFlyweight(String name){ 7 | this.name = name; 8 | } 9 | @Override 10 | public void operation() { 11 | // TODO Auto-generated method stub 12 | System.out.println("concreteflyweight:" + name); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/flyweight/Flyweight.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.flyweight; 2 | 3 | public abstract class Flyweight { 4 | public abstract void operation(); 5 | } 6 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/flyweight/FlyweightFactory.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.flyweight; 2 | 3 | import java.util.HashMap; 4 | /** 5 | * 6 | * @ClassName: FlyweightFactory 7 | * @Description: TODO 8 | * @author wangzekeng 9 | * @date 2017年10月11日 下午4:42:49 10 | * 11 | */ 12 | public class FlyweightFactory { 13 | private HashMap map = new HashMap(); 14 | 15 | 16 | public Flyweight getFlyweight(String name){ 17 | Flyweight flyweight = map.get(name); 18 | if(flyweight == null){ 19 | flyweight = new ConcreteFlyweight(name); 20 | map.put(name, flyweight); 21 | } 22 | return flyweight; 23 | } 24 | 25 | public int getFlyweightSize(){ 26 | return map.size(); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/handler/Client.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.handler; 2 | /** 3 | * 责任链模式 4 | * @ClassName: Client 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年10月13日 上午11:01:56 8 | * 9 | */ 10 | public class Client { 11 | public static void main(String[] args) { 12 | ProjectManager projectManager = new ProjectManager(); 13 | DeptManager deptManager = new DeptManager(); 14 | GeneralManager generalManager = new GeneralManager(); 15 | projectManager.setSuccessor(deptManager); 16 | deptManager.setSuccessor(generalManager); 17 | projectManager.handleRequest("张三", 10000); 18 | deptManager.handleRequest("李四", 100); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/handler/DeptManager.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.handler; 2 | 3 | import org.omg.PortableInterceptor.USER_EXCEPTION; 4 | 5 | public class DeptManager extends Handler{ 6 | 7 | @Override 8 | public void handleRequest(String name ,int fee) { 9 | // TODO Auto-generated method stub 10 | if(fee<=1000){ 11 | if(name.equals("张三")){ 12 | System.out.println("成功:部门经理同意" + name + "的经费申请,金额为:" + fee + "元"); 13 | }else{ 14 | System.out.println("失败:部门经理不同意" + name + "的经费申请,金额为:" + fee + "元"); 15 | } 16 | }else{ 17 | if(getSuccessor() != null){ 18 | getSuccessor().handleRequest(name, fee); 19 | } 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/handler/GeneralManager.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.handler; 2 | 3 | import org.omg.PortableInterceptor.USER_EXCEPTION; 4 | 5 | public class GeneralManager extends Handler{ 6 | 7 | @Override 8 | public void handleRequest(String name ,int fee) { 9 | // TODO Auto-generated method stub 10 | if(fee>1000){ 11 | if(name.equals("张三")){ 12 | System.out.println("成功:总经理同意" + name + "的经费申请,金额为:" + fee + "元"); 13 | }else{ 14 | System.out.println("失败:总经理不同意" + name + "的经费申请,金额为:" + fee + "元"); 15 | } 16 | }else{ 17 | if(getSuccessor() != null){ 18 | getSuccessor().handleRequest(name, fee); 19 | } 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/handler/Handler.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.handler; 2 | 3 | public abstract class Handler { 4 | private Handler successor = null; 5 | 6 | protected Handler getSuccessor(){ 7 | return successor; 8 | } 9 | 10 | public void setSuccessor(Handler handler){ 11 | this.successor = handler; 12 | } 13 | 14 | public abstract void handleRequest(String name ,int fee); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/handler/ProjectManager.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.handler; 2 | 3 | import org.omg.PortableInterceptor.USER_EXCEPTION; 4 | 5 | public class ProjectManager extends Handler{ 6 | 7 | @Override 8 | public void handleRequest(String name ,int fee) { 9 | // TODO Auto-generated method stub 10 | if(fee<=500){ 11 | if(name.equals("张三")){ 12 | System.out.println("成功:项目经理同意" + name + "的经费申请,金额为:" + fee + "元"); 13 | }else{ 14 | System.out.println("失败:项目经理不同意" + name + "的经费申请,金额为:" + fee + "元"); 15 | } 16 | }else{ 17 | if(getSuccessor() != null){ 18 | getSuccessor().handleRequest(name, fee); 19 | } 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/javaObserve/TestObserver.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.javaObserve; 2 | /** 3 | * 4 | * @ClassName: TestObserver 5 | * java自带观察者模式测试 6 | * @author wangzekeng 7 | * @date 2016年12月7日 下午3:53:02 8 | * 9 | */ 10 | public class TestObserver { 11 | public static void main(String [] args){ 12 | Watched watched = new Watched(); 13 | Watcher watcher1 = new Watcher(watched); 14 | Watcher watcher2 = new Watcher(watched); 15 | watched.setData("hhh"); 16 | watched.setData("bbb"); 17 | watched.setData("bbb"); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/javaObserve/Watched.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.javaObserve; 2 | 3 | import java.util.Observable; 4 | 5 | public class Watched extends Observable{ 6 | private String data =""; 7 | 8 | public String getData() { 9 | return data; 10 | } 11 | 12 | public void setData(String data) { 13 | if(!data.equals(this.data)){ 14 | // System.out.println("this.data:"+this.data); 15 | // System.out.println("new data:"+data); 16 | this.data = data; 17 | setChanged(); 18 | 19 | } 20 | notifyObservers(); 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/javaObserve/Watcher.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.javaObserve; 2 | import java.util.Observable; 3 | import java.util.Observer; 4 | public class Watcher implements Observer{ 5 | 6 | public Watcher(Observable o) { 7 | o.addObserver(this); 8 | } 9 | 10 | @Override 11 | public void update(Observable o, Object arg1) { 12 | // TODO Auto-generated method stub 13 | System.out.println("状态发生改变:" + ((Watched)o).getData()); 14 | 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/nativeObserve/Observable.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.nativeObserve; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * 8 | * @ClassName: Observable 9 | * @Description: 被观察者:注册,注销,通知。通用定义为泛型。 10 | * @author wangzekeng 11 | * @date 2016年12月12日 下午3:05:19 12 | * 13 | */ 14 | public class Observable { 15 | private List> observes = new ArrayList>(); 16 | 17 | public void register(Observe observe) { 18 | if (observe != null) { 19 | synchronized (this) { 20 | if (!observes.contains(observe)) 21 | observes.add(observe); 22 | } 23 | } 24 | } 25 | 26 | public void unRegister(Observe observe){ 27 | if (observe != null) { 28 | synchronized (this) { 29 | if (observes.contains(observe)) 30 | observes.remove(observe); 31 | } 32 | } 33 | } 34 | 35 | public void notifyObservers(T data){ 36 | for(Observe observe : observes){ 37 | observe.update(this, data); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/nativeObserve/Observe.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.nativeObserve; 2 | /** 3 | * 4 | * @ClassName: Observe 5 | * 观察者,也是泛型 6 | * @author wangzekeng 7 | * @date 2016年12月12日 下午3:35:13 8 | * 9 | * @param 10 | */ 11 | public interface Observe { 12 | void update(Observable observable,T data); 13 | } 14 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/nativeObserve/ObserveData.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.nativeObserve; 2 | /** 3 | * 4 | * @ClassName: ObserveData 5 | * 被观察的数据 6 | * @author wangzekeng 7 | * @date 2016年12月12日 下午3:26:35 8 | * 9 | */ 10 | public class ObserveData { 11 | private String description; 12 | 13 | public String getDescription() { 14 | return description; 15 | } 16 | 17 | 18 | public void setDescription(String description) { 19 | this.description = description; 20 | } 21 | 22 | @Override 23 | public String toString() { 24 | return " [description=" + description + "]"; 25 | } 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/nativeObserve/TestObserve.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.nativeObserve; 2 | /** 3 | * 4 | * @ClassName: 观察者模式的使用 5 | * 创建被观察者,通过被观察者注册观察者。生成数据,传入被观察者的通知方法。 6 | * @author wangzekeng 7 | * @date 2016年12月12日 下午3:25:17 8 | * 9 | */ 10 | public class TestObserve { 11 | public static void main(String[] args) { 12 | Observable mObservable = new Observable(); 13 | Observe observe1 = new Observe() { 14 | 15 | @Override 16 | public void update(Observable observable, 17 | ObserveData data) { 18 | // TODO Auto-generated method stub 19 | System.out.println("观察者1:" + data.toString()); 20 | } 21 | }; 22 | 23 | Observe observe2 = new Observe() { 24 | 25 | @Override 26 | public void update(Observable observable, 27 | ObserveData data) { 28 | // TODO Auto-generated method stub 29 | System.out.println("观察者2:" + data.toString()); 30 | } 31 | }; 32 | 33 | mObservable.register(observe1); 34 | mObservable.register(observe2); 35 | 36 | ObserveData data1 = new ObserveData(); 37 | data1.setDescription("太阳出来了"); 38 | mObservable.notifyObservers(data1); 39 | 40 | ObserveData data2 = new ObserveData(); 41 | data2.setDescription("下雨了"); 42 | mObservable.unRegister(observe2); 43 | mObservable.notifyObservers(data2); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/proto/Person.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.proto; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | /** 6 | * 7 | * @ClassName: Person 8 | * @Description: 原型模式,实现clone方法 9 | * @author wangzekeng 10 | * @date 2017年1月7日 下午2:37:57 11 | * 12 | */ 13 | public class Person implements Cloneable{ 14 | @Override 15 | public String toString() { 16 | return "Person [name=" + name + ", age=" + age + ", height=" + height 17 | + ", weight=" + weight + ", hobbies=" + hobbies + "]"; 18 | } 19 | private String name; 20 | private int age; 21 | private int height; 22 | private int weight; 23 | private List hobbies = new ArrayList(); 24 | public String getName() { 25 | return name; 26 | } 27 | public void setName(String name) { 28 | this.name = name; 29 | } 30 | public int getAge() { 31 | return age; 32 | } 33 | public void setAge(int age) { 34 | this.age = age; 35 | } 36 | public int getHeight() { 37 | return height; 38 | } 39 | public void setHeight(int height) { 40 | this.height = height; 41 | } 42 | public int getWeight() { 43 | return weight; 44 | } 45 | public void setWeight(int weight) { 46 | this.weight = weight; 47 | } 48 | public List getHobbies() { 49 | return hobbies; 50 | } 51 | public void setHobbies(List hobbies) { 52 | this.hobbies = hobbies; 53 | } 54 | //重写clone 55 | @Override 56 | public Object clone(){ 57 | Person person = null; 58 | try { 59 | person = (Person) super.clone(); 60 | person.name = this.name; 61 | person.age = this.age; 62 | person.weight = this.weight; 63 | person.height = this.height; 64 | person.hobbies = this.hobbies; 65 | 66 | } catch (CloneNotSupportedException e) { 67 | // TODO Auto-generated catch block 68 | e.printStackTrace(); 69 | } 70 | return person; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/proto/TestProto.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.proto; 2 | 3 | public class TestProto { 4 | public static void main(String[] args) { 5 | Person person1 = new Person(); 6 | person1.setName("张三"); 7 | person1.setAge(11); 8 | person1.setHeight(12); 9 | person1.setWeight(12); 10 | System.out.println(person1.toString()); 11 | 12 | Person person2 = (Person) person1.clone(); 13 | person2.setName("李四"); 14 | System.out.println(person2.toString()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/proxy/Client.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.proxy; 2 | /** 3 | * 模拟客户端 4 | * @ClassName: Client 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年9月11日 上午11:29:54 8 | * 9 | */ 10 | public class Client { 11 | public static void main(String[] args) { 12 | //静态代理 13 | // UserManager userManager = new UserManagerProxy(new UserManagerImpl()); 14 | // userManager.addUser(1, "wangze"); 15 | 16 | 17 | //动态代理 18 | //new ProxyManager().newProxyInstance(new UserManagerImpl()).addUser(1, "wangze"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/proxy/ProxyManager.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.proxy; 2 | 3 | import java.lang.reflect.InvocationHandler; 4 | import java.lang.reflect.Method; 5 | import java.lang.reflect.Proxy; 6 | 7 | public class ProxyManager implements InvocationHandler{ 8 | private Object targetObject;//目标对象 9 | 10 | public Object newProxyInstance(Object target){ 11 | targetObject = target; 12 | //newProxyInstance会返回一个Object,实际上是target的接口类型 13 | return Proxy.newProxyInstance(target.getClass().getClassLoader(),target.getClass().getInterfaces(),this); 14 | } 15 | 16 | @Override 17 | public Object invoke(Object proxy, Method method, Object[] args) 18 | throws Throwable { 19 | Object ret = null; 20 | try{ 21 | 22 | System.out.println("start->"); 23 | ret = method.invoke(targetObject, args); 24 | System.out.println("success->"); 25 | }catch(Exception e){ 26 | System.out.println("fail"); 27 | throw e; 28 | } 29 | return ret; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/proxy/UserManager.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.proxy; 2 | /** 3 | * 代理接口 subject 客户端可见的类 4 | * @ClassName: UserManager 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年9月11日 上午11:03:37 8 | * 9 | */ 10 | public interface UserManager { 11 | public void addUser(int uid,String name); 12 | 13 | public void delUser(int uid); 14 | 15 | public void modifyUser(int uid,String name); 16 | } 17 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/proxy/UserManagerImpl.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.proxy; 2 | 3 | /** 4 | * 代理的委托类,也就是具体的实现类 5 | * @ClassName: UserManagerImpl 6 | * @Description: TODO 7 | * @author wangzekeng 8 | * @date 2017年9月11日 上午11:09:21 9 | * 10 | */ 11 | 12 | 13 | public class UserManagerImpl implements UserManager{ 14 | 15 | @Override 16 | public void addUser(int uid, String name) { 17 | // TODO Auto-generated method stub 18 | System.out.println("UserManagerImpl addUser()"); 19 | } 20 | 21 | @Override 22 | public void delUser(int uid) { 23 | // TODO Auto-generated method stub 24 | System.out.println("UserManagerImpl delUser()"); 25 | } 26 | 27 | @Override 28 | public void modifyUser(int uid, String name) { 29 | // TODO Auto-generated method stub 30 | System.out.println("UserManagerImpl modifyUser()"); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/proxy/UserManagerProxy.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.proxy; 2 | 3 | /** 4 | * 优点 5 | * 静态代理类 解除接口和实现类的耦合 增加预处理,日记,实现后续处理的操作 6 | * 7 | * 缺点 8 | * 代理类需要实现所有接口方法,代码冗余 9 | * 静态代理,一个接口就要实现一个代理类,多个接口的时候需要写很多代理类 10 | * 11 | * @ClassName: UserManagerProxy 12 | * @Description: TODO 13 | * @author wangzekeng 14 | * @date 2017年9月11日 上午11:16:51 15 | * 16 | */ 17 | public class UserManagerProxy implements UserManager { 18 | UserManager userManager; 19 | 20 | public UserManagerProxy(UserManager userManager) { 21 | 22 | this.userManager = userManager; 23 | 24 | } 25 | 26 | @Override 27 | public void addUser(int uid, String name) { 28 | // 添加日志功能 29 | try { 30 | System.out.println("start -> addUser()");//调用添加用户功能 31 | userManager.addUser(uid, name); 32 | System.out.println("success -> addUser()");//调用添加用户成功 33 | } catch (Exception e) { 34 | // TODO: handle exception 35 | System.out.println("fail -> addUser()");//调用添加用户失败 36 | } 37 | } 38 | 39 | @Override 40 | public void delUser(int uid) { 41 | // TODO Auto-generated method stub 42 | userManager.delUser(uid); 43 | } 44 | 45 | @Override 46 | public void modifyUser(int uid, String name) { 47 | // TODO Auto-generated method stub 48 | userManager.modifyUser(uid, name); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/simpleFactory/AndroidPhone.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.simpleFactory; 2 | 3 | public class AndroidPhone implements IPhone{ 4 | protected AndroidPhone(){}; 5 | @Override 6 | public void getOS() { 7 | // TODO Auto-generated method stub 8 | System.out.println("i am android"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/simpleFactory/IPhone.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.simpleFactory; 2 | 3 | public interface IPhone { 4 | public void getOS(); 5 | } 6 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/simpleFactory/IReflectGenerator.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.simpleFactory; 2 | 3 | public interface IReflectGenerator { 4 | public T generatePhone(Class cls)throws Exception; 5 | } 6 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/simpleFactory/IosPhone.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.simpleFactory; 2 | 3 | public class IosPhone implements IPhone{ 4 | protected IosPhone(){}; 5 | @Override 6 | public void getOS() { 7 | // TODO Auto-generated method stub 8 | System.out.println("i am ios"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/simpleFactory/MainClient.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.simpleFactory; 2 | /** 3 | * 简单工厂模式 4 | * 5 | * 简单工厂模式,工厂没有接口或者抽象类,通过flag来生成不同产品 6 | * 7 | * 可以结合反射来解除耦合 8 | * 9 | * @ClassName: IosGenertor 10 | * @Description: TODO 11 | * @author wangzekeng 12 | * @date 2017年9月13日 下午5:50:56 13 | * 14 | */ 15 | public class MainClient { 16 | public static void main(String[] args) { 17 | IPhone android = PhoneGenerator.generatePhone(PhoneGenerator.ANDROID); 18 | android.getOS(); 19 | IPhone ios = PhoneGenerator.generatePhone(PhoneGenerator.IOS); 20 | ios.getOS(); 21 | 22 | 23 | //通过反射 24 | ReflectPhoneGenerator reflectPhoneGenerator = new ReflectPhoneGenerator(); 25 | try { 26 | reflectPhoneGenerator.generatePhone(AndroidPhone.class).getOS(); 27 | } catch (Exception e) { 28 | System.out.println("可以捕获异常"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/simpleFactory/PhoneGenerator.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.simpleFactory; 2 | /** 3 | * 简单工厂,也叫静态工厂 4 | * @ClassName: PhoneGenerator 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年9月14日 上午10:14:29 8 | * 9 | */ 10 | public class PhoneGenerator { 11 | public static final int ANDROID = 1; 12 | public static final int IOS = 2; 13 | public static final int BARRY = 3; 14 | public static IPhone generatePhone(int flag){ 15 | IPhone phone = null; 16 | switch (flag) { 17 | case ANDROID: 18 | phone = new IosPhone(); 19 | break; 20 | case IOS: 21 | phone = new AndroidPhone(); 22 | break; 23 | default: 24 | break; 25 | } 26 | return phone; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/simpleFactory/ReflectPhoneGenerator.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.simpleFactory; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | /** 6 | * 7 | * 结合反射的工厂类 8 | * 9 | * 结合反射无需写switch,新增加产品也无需修改此类,符合开闭原则 10 | * 同时产品构造函数可以私有化,防止客户通过构造函数构造 11 | * 12 | * @ClassName: ReflectPhoneGenerator 13 | * @Description: TODO 14 | * @author wangzekeng 15 | * @date 2017年9月14日 上午10:34:41 16 | * 17 | */ 18 | public class ReflectPhoneGenerator implements IReflectGenerator{ 19 | 20 | private Map phoneMap = new HashMap();//缓存 21 | @Override 22 | public T generatePhone(Class cls) throws Exception { 23 | // TODO Auto-generated method stub 24 | T phone = null; 25 | String phoneName = cls.getSimpleName(); 26 | if(phoneMap.containsKey(phoneName)){ 27 | 28 | phone = (T)phoneMap.get(phoneName); 29 | }else{ 30 | cls.getDeclaredConstructor().setAccessible(true); //修改访问权限 31 | phone = cls.newInstance(); 32 | phoneMap.put(phoneName, phone); 33 | } 34 | return phone; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/singleton/EnumSingleTon.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.singleton; 2 | /** 3 | * 4 | * @ClassName: EnumSingleTon 5 | * 枚举类型单例模式,适合多线程 6 | * @author wangzekeng 7 | * @date 2016年12月7日 下午3:42:23 8 | * 9 | */ 10 | public enum EnumSingleTon { 11 | instance;//定义一个枚举元素,他就是单例的实例 12 | public void doSomeThing(){ 13 | // 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/singleton/HungerSingleTon.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.singleton; 2 | /** 3 | * 4 | * @ClassName: HungerSingleTon 5 | * 最基本的单例模式,饿汉模式,适合初始化花费较少的程序,同时适合单线程也适合多线程 6 | * @author wangzekeng 7 | * @date 2016年12月7日 下午2:31:01 8 | * 9 | */ 10 | public class HungerSingleTon { 11 | private static HungerSingleTon instance = new HungerSingleTon();//不通过实例调用,通过类中方法获得实例必须静态 12 | private HungerSingleTon(){} 13 | public static HungerSingleTon getInstance(){ 14 | return instance; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/singleton/LazySingleTon.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.singleton; 2 | /** 3 | * 4 | * @ClassName: LazySingleTon 5 | * 基本单例模式,懒汉模式,适合单线程,在初始化耗费多资源时也适用 6 | * @author wangzekeng 7 | * @date 2016年12月7日 下午2:38:20 8 | * 9 | */ 10 | public class LazySingleTon { 11 | private static LazySingleTon instance = null; 12 | private LazySingleTon(){} 13 | public static LazySingleTon getInstance(){ 14 | if(instance == null){ 15 | instance = new LazySingleTon(); 16 | } 17 | return instance; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/singleton/MultiLazySingleTon.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.singleton; 2 | /** 3 | * 4 | * @ClassName: MultiLazySingleTon 5 | * 双重校验锁单例模式,使得懒汉模式适合多线程 6 | * @author wangzekeng 7 | * @date 2016年12月7日 下午2:44:59 8 | * 9 | */ 10 | public class MultiLazySingleTon { 11 | private static volatile MultiLazySingleTon instance = null;//在执行instance=new Singleton();时,并不是原子语句.volatile禁止指令优化重排 12 | private MultiLazySingleTon(){} 13 | public static MultiLazySingleTon getInstance(){ 14 | if( instance == null){ //确保了只有第一次调用单例的时候才会做同步 15 | synchronized (MultiLazySingleTon.class) {//防止多线程下创建多个实例 16 | if(instance == null){ 17 | instance = new MultiLazySingleTon(); 18 | } 19 | } 20 | } 21 | return instance; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/singleton/StaticClassSingleTon.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.singleton; 2 | 3 | import java.security.PublicKey; 4 | 5 | /** 6 | * 7 | * @ClassName: StaticClassSingleTon 8 | * 常用模式,静态内部类单例模式,利用jvm提供的类加载模式,静态内部类是要在有引用了以后才会装载到内存的 9 | * @author wangzekeng 10 | * @date 2016年12月7日 下午2:56:15 11 | * 12 | */ 13 | public class StaticClassSingleTon { 14 | private StaticClassSingleTon(){} 15 | private static class StaticClassSingleTonHolder{ 16 | private static StaticClassSingleTon instance = new StaticClassSingleTon(); 17 | } 18 | public static StaticClassSingleTon getInstance(){ 19 | return StaticClassSingleTonHolder.instance; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/state/VoteContext.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.state; 2 | 3 | public class VoteContext { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/state/VoteState.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.state; 2 | 3 | public interface VoteState { 4 | /** 5 | * 6 | * @param user 投票人 7 | * @param voteItem 投票项 8 | * @param voteContext 上下文 9 | */ 10 | public void vote(String user,String voteItem,VoteContext voteContext); 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/strategy/PlaneStrategy.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.strategy; 2 | 3 | public class PlaneStrategy implements Strategy{ 4 | 5 | @Override 6 | public void travel() { 7 | System.out.println(" by plane"); 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/strategy/Strategy.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.strategy; 2 | /** 3 | * 4 | * @ClassName: Strategy 5 | * @Description: 创建一个接口放共有方法,不同实现 6 | * @author wangzekeng 7 | * @date 2016年12月8日 下午4:43:49 8 | * 9 | */ 10 | public interface Strategy { 11 | public void travel(); 12 | } 13 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/strategy/StrategyContext.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.strategy; 2 | 3 | /** 4 | * 5 | * @ClassName: StrategyContext 6 | * @Description: 创建一个包装strategy的类来进行管理,此类不再需要修改,新增策略时只需再写类继承接口,符合开放封闭原则 7 | * @author wangzekeng 8 | * @date 2016年12月8日 下午4:46:29 9 | * 10 | */ 11 | public class StrategyContext { 12 | private Strategy strategy; 13 | 14 | public Strategy getStrategy() { 15 | return strategy; 16 | } 17 | 18 | public void setStrategy(Strategy strategy) { 19 | this.strategy = strategy; 20 | } 21 | 22 | public void travel() { 23 | if (strategy != null) { 24 | strategy.travel(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/strategy/TestStrategy.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.strategy; 2 | 3 | public class TestStrategy { 4 | 5 | public static void main(String[] args) { 6 | 7 | StrategyContext plane = new StrategyContext(); 8 | plane.setStrategy(new PlaneStrategy()); 9 | plane.travel(); 10 | 11 | StrategyContext walk = new StrategyContext(); 12 | walk.setStrategy(new WalkStrategy()); 13 | walk.travel(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /JavaStudy/src/com/designPattern/strategy/WalkStrategy.java: -------------------------------------------------------------------------------- 1 | package com.designPattern.strategy; 2 | 3 | public class WalkStrategy implements Strategy{ 4 | 5 | @Override 6 | public void travel() { 7 | // TODO Auto-generated method stub 8 | System.out.println("by walk"); 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/generic/GenericClass.java: -------------------------------------------------------------------------------- 1 | package com.java.generic; 2 | 3 | /** 4 | * 泛型类 5 | * @ClassName: GenericClass 6 | * @Description: TODO 7 | * @author wangzekeng 8 | * @date 2017年9月12日 下午3:17:20 9 | * 10 | */ 11 | public class GenericClass { 12 | 13 | public static void main(String[] args) { 14 | Box name = new Box("test"); 15 | System.out.println("name:" + name.getData()); 16 | } 17 | 18 | /* 19 | * 泛型类 20 | * 在类后面加<>,T是类型变量,可以多个类型变量。 21 | * 类型变量多用大写字母表示 22 | * 用变量E表示集合的元素类型 23 | * K和V分别表示关键字与值的类型。 24 | * 字母U和S表示“任意类型”。 25 | */ 26 | 27 | static class Box { 28 | 29 | private T data;//T设定成员变量类型 30 | 31 | public Box() { 32 | 33 | } 34 | 35 | public Box(T data) { 36 | this.data = data; 37 | } 38 | 39 | public T getData() { 40 | return data; 41 | } 42 | 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/generic/GenericFunction.java: -------------------------------------------------------------------------------- 1 | package com.java.generic; 2 | 3 | import java.util.Date; 4 | /** 5 | *泛型方法 6 | * @ClassName: GenericFunction 7 | * @Description: TODO 8 | * @author wangzekeng 9 | * @date 2017年9月12日 下午3:53:26 10 | * 11 | */ 12 | public class GenericFunction { 13 | public static void main(String[] args) { 14 | //这时候返回时一个Date对象,无需强转化。可以直接.获得Date相关方法 15 | Number time = show(new Date(), "gg").getTime(); 16 | System.out.println(time); 17 | } 18 | 19 | //注意在返回值前需要来声明这是一个泛型方法 20 | public static T show(T t,U u){ 21 | System.out.println(t); 22 | System.out.println(u); 23 | return t; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/generic/GenericInterface.java: -------------------------------------------------------------------------------- 1 | package com.java.generic; 2 | /** 3 | * 泛型接口 4 | * @ClassName: GenericInterface 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年9月12日 下午3:25:57 8 | * 9 | * @param 10 | * @param 11 | */ 12 | public interface GenericInterface { 13 | void show(T t,U u); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/generic/GenericSpecial.java: -------------------------------------------------------------------------------- 1 | package com.java.generic; 2 | 3 | public class GenericSpecial { 4 | 5 | //上界,T只能是Number或者它的子类 6 | static class Box1 { 7 | 8 | private T data;//T设定成员变量类型 9 | 10 | public Box1() { 11 | 12 | } 13 | 14 | public Box1(T data) { 15 | this.data = data; 16 | } 17 | 18 | public T getData() { 19 | return data; 20 | } 21 | 22 | } 23 | 24 | 25 | public static void main(String[] args) { 26 | //Box1 box = new Box1(); 会报错 27 | Box1 box = new Box1(1); 28 | System.out.println(box.getData()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/generic/InterfaceTest.java: -------------------------------------------------------------------------------- 1 | package com.java.generic; 2 | 3 | import java.util.Date; 4 | /** 5 | * 泛型接口 6 | * @ClassName: InterfaceTest 7 | * @Description: TODO 8 | * @author wangzekeng 9 | * @date 2017年9月12日 下午3:26:15 10 | * 11 | */ 12 | 13 | //需要传入实参类型String,Date,作为限定 14 | public class InterfaceTest implements GenericInterface { 15 | 16 | @Override 17 | public void show(String t, Date u) { 18 | // TODO Auto-generated method stub 19 | System.out.println(t); 20 | System.out.println(u); 21 | } 22 | 23 | 24 | public static void main(String[] args) { 25 | InterfaceTest test = new InterfaceTest(); 26 | //调用方法时会做类型检测 27 | test.show("1", new Date()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/inject/Apple.java: -------------------------------------------------------------------------------- 1 | package com.java.inject; 2 | 3 | import com.java.inject.FruitColor.Color; 4 | 5 | public class Apple { 6 | @FruitName(value = "Apple") 7 | public String name; 8 | 9 | @FruitColor(fruitColor = Color.RED) 10 | public String color; 11 | 12 | @FruitProvider(id = 1 , name = "apple" , address = "wangze.com") 13 | public String provider; 14 | 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public String getColor() { 25 | return color; 26 | } 27 | 28 | public void setColor(String color) { 29 | this.color = color; 30 | } 31 | 32 | public String getProvider() { 33 | return provider; 34 | } 35 | 36 | public void setProvider(String provider) { 37 | this.provider = provider; 38 | } 39 | 40 | 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/inject/FruitColor.java: -------------------------------------------------------------------------------- 1 | package com.java.inject; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface FruitColor { 11 | public enum Color{BULE,RED,GREEN}; 12 | 13 | 14 | Color fruitColor() default Color.BULE; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/inject/FruitName.java: -------------------------------------------------------------------------------- 1 | package com.java.inject; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface FruitName { 11 | String value() default ""; 12 | } 13 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/inject/FruitProvider.java: -------------------------------------------------------------------------------- 1 | package com.java.inject; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target(ElementType.FIELD) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface FruitProvider { 11 | int id() default -1; 12 | 13 | String name() default ""; 14 | 15 | String address() default ""; 16 | } 17 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/inject/MainClient.java: -------------------------------------------------------------------------------- 1 | package com.java.inject; 2 | 3 | import java.lang.annotation.Annotation; 4 | import java.lang.reflect.Field; 5 | 6 | public class MainClient { 7 | 8 | public static void main(String[] args) { 9 | fruitUtils(Apple.class); 10 | 11 | } 12 | 13 | 14 | public static void fruitUtils(Class cls){ 15 | 16 | Field[] fields = cls.getDeclaredFields(); 17 | 18 | for(Field field: fields){ 19 | if(field.isAnnotationPresent(FruitName.class)){ 20 | FruitName fuiltName = field.getAnnotation(FruitName.class); 21 | System.out.println("fuilt name:" + fuiltName.value()); 22 | 23 | 24 | }else if(field.isAnnotationPresent(FruitColor.class)){ 25 | FruitColor fruitColor = field.getAnnotation(FruitColor.class); 26 | System.out.println("fruit color:" + fruitColor.fruitColor().toString()); 27 | 28 | 29 | }else if(field.isAnnotationPresent(FruitProvider.class)){ 30 | FruitProvider fruitProvider = field.getAnnotation(FruitProvider.class); 31 | System.out.println("fruit provider:"+ fruitProvider.id() + "+" + fruitProvider.name() 32 | + "+" + fruitProvider.address()); 33 | 34 | 35 | } 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/reflect/TestReflect.java: -------------------------------------------------------------------------------- 1 | package com.java.reflect; 2 | 3 | import java.lang.reflect.Field; 4 | 5 | public class TestReflect { 6 | public static void main(String[] args) { 7 | try { 8 | Class cls = Class.forName("com.java.reflect.UserManagerImpl"); 9 | //getSimpleName() : 获取类名 UserManager 10 | System.out.println(cls.getSimpleName()); 11 | 12 | //getName() : 获取完整类名 com.java.reflect.UserManager 13 | System.out.println(cls.getName()); 14 | 15 | //ls.getInterfaces() : 获取该类实现的接口com.java.reflect.UserManager,可能有多个implements 16 | Class[] ifs = cls.getInterfaces(); 17 | for(Class i : ifs){ 18 | System.out.println(i.getName()); 19 | } 20 | 21 | 22 | //getFields:获取public的成员变量 23 | Field[] fds = cls.getFields(); 24 | for(Field fd : fds){ 25 | Class type = fd.getType(); 26 | String strType = type.getName(); 27 | String strName = fd.getName(); 28 | System.out.println("field name:" + strName + " field type:" + strType); 29 | } 30 | 31 | 32 | } catch (ClassNotFoundException e) { 33 | // TODO Auto-generated catch block 34 | e.printStackTrace(); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/reflect/UserManager.java: -------------------------------------------------------------------------------- 1 | package com.java.reflect; 2 | /** 3 | * 代理接口 subject 客户端可见的类 4 | * @ClassName: UserManager 5 | * @Description: TODO 6 | * @author wangzekeng 7 | * @date 2017年9月11日 上午11:03:37 8 | * 9 | */ 10 | public interface UserManager { 11 | 12 | public void addUser(int uid,String name); 13 | 14 | public void delUser(int uid); 15 | 16 | public void modifyUser(int uid,String name); 17 | } 18 | -------------------------------------------------------------------------------- /JavaStudy/src/com/java/reflect/UserManagerImpl.java: -------------------------------------------------------------------------------- 1 | package com.java.reflect; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 代理的委托类,也就是具体的实现类 7 | * @ClassName: UserManagerImpl 8 | * @Description: TODO 9 | * @author wangzekeng 10 | * @date 2017年9月11日 上午11:09:21 11 | * 12 | */ 13 | 14 | 15 | public class UserManagerImpl implements UserManager{ 16 | private int age; 17 | public String name; 18 | protected double money; 19 | @Override 20 | public void addUser(int uid, String name) { 21 | // TODO Auto-generated method stub 22 | System.out.println("UserManagerImpl addUser()"); 23 | } 24 | 25 | @Override 26 | public void delUser(int uid) { 27 | // TODO Auto-generated method stub 28 | System.out.println("UserManagerImpl delUser()"); 29 | } 30 | 31 | @Override 32 | public void modifyUser(int uid, String name) { 33 | // TODO Auto-generated method stub 34 | System.out.println("UserManagerImpl modifyUser()"); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /JavaStudy/src/com/webcrawler/simple/Test.java: -------------------------------------------------------------------------------- 1 | package com.webcrawler.simple; 2 | import java.io.IOException; 3 | 4 | import org.jsoup.Jsoup; 5 | import org.jsoup.nodes.Document; 6 | import org.jsoup.nodes.Element; 7 | import org.jsoup.select.Elements; 8 | public class Test { 9 | public static void Get_Url(String url) { 10 | try { 11 | Document doc = Jsoup.connect(url) 12 | //.data("query", "Java") 13 | //.userAgent("头部") 14 | //.cookie("auth", "token") 15 | //.timeout(3000) 16 | //.post() 17 | .get(); 18 | 19 | //得到html的所有东西 20 | Element content = doc.getElementById("body"); 21 | //分离出html下...之间的所有东西 22 | Elements links = content.getElementsByTag("a"); 23 | //Elements links = doc.select("a[href]"); 24 | // 扩展名为.png的图片 25 | Elements pngs = doc.select("img[src$=.png]"); 26 | // class等于masthead的div标签 27 | Element masthead = doc.select("div.masthead").first(); 28 | 29 | for (Element link : links) { 30 | //得到...里面的网址 31 | String linkHref = link.attr("href"); 32 | //得到...里面的汉字 33 | String linkText = link.text(); 34 | System.out.println(linkText + " : " + linkHref); 35 | } 36 | } catch (IOException e) { 37 | e.printStackTrace(); 38 | } 39 | } 40 | 41 | public static void main(String[] args) { 42 | Get_Url("http://news.baidu.com/"); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /JavaStudy/src/commons-lang.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/JavaStudy/src/commons-lang.jar -------------------------------------------------------------------------------- /MyUtil/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /MyUtil/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /MyUtil/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /MyUtil/.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /MyUtil/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | -------------------------------------------------------------------------------- /MyUtil/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /MyUtil/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MyUtil/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /MyUtil/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /MyUtil/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.common.myutil" 8 | minSdkVersion 15 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.3.1' 28 | compile 'com.android.support.constraint:constraint-layout:+' 29 | testCompile 'junit:junit:4.12' 30 | } 31 | -------------------------------------------------------------------------------- /MyUtil/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /MyUtil/app/src/androidTest/java/com/common/myutil/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | import android.widget.Toast; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumentation test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() throws Exception { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getTargetContext(); 24 | 25 | assertEquals("com.common.myutil", appContext.getPackageName()); 26 | } 27 | @Test 28 | public void testToast(){ 29 | Toast toast = Toast.makeText(InstrumentationRegistry.getTargetContext(),"hhhhh",Toast.LENGTH_LONG); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/ActivityList.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil; 2 | 3 | 4 | import com.common.myutil.utils.LogUtils; 5 | 6 | public class ActivityList { 7 | private String activityName; 8 | private String title; 9 | private String content; 10 | 11 | public ActivityList(String activityName) { 12 | this.activityName = activityName; 13 | } 14 | 15 | public void setTitle(String title) { 16 | this.title = title; 17 | } 18 | 19 | public void setContent(String content) { 20 | this.content = content; 21 | } 22 | 23 | 24 | public String getTitle() { 25 | return title; 26 | } 27 | 28 | public String getContent() { 29 | return content; 30 | } 31 | 32 | public Class getActivityClass() { 33 | try { 34 | Class activityClass = Class.forName("com.common.myutil.activity." + activityName); 35 | return activityClass; 36 | } catch (ClassNotFoundException e) { 37 | LogUtils.e("找不到类"); 38 | return null; 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/articleListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil; 2 | 3 | import java.util.List; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ArrayAdapter; 10 | import android.widget.TextView; 11 | 12 | public class articleListAdapter extends ArrayAdapter { 13 | public articleListAdapter(Context context, int resource, List objects) { 14 | super(context, resource, objects); 15 | // TODO Auto-generated constructor stub 16 | 17 | } 18 | @Override 19 | public View getView(int position, View convertView, ViewGroup parent) { 20 | // TODO Auto-generated method stub 21 | //return super.getView(position, convertView, parent); 22 | 23 | 24 | final ActivityList activityList = getItem(position); 25 | View view; 26 | ViewHolder viewHolder; 27 | if(convertView==null){ 28 | view = LayoutInflater.from(getContext()).inflate(R.layout.article_item, null); 29 | viewHolder = new ViewHolder(); 30 | viewHolder.juziTitle =(TextView) view.findViewById(R.id.tv_speak_title); 31 | viewHolder.juziContent =(TextView) view.findViewById(R.id.tv_speak_content); 32 | view.setTag(viewHolder); 33 | }else { 34 | view = convertView; 35 | viewHolder = (ViewHolder) view.getTag(); 36 | } 37 | viewHolder.juziTitle.setText(activityList.getTitle()); 38 | viewHolder.juziContent.setText(activityList.getContent()); 39 | view.setOnClickListener(new View.OnClickListener() { 40 | @Override 41 | public void onClick(View v) { 42 | Intent intent = new Intent(getContext(),activityList.getActivityClass()); 43 | getContext().startActivity(intent); 44 | } 45 | }); 46 | return view; 47 | 48 | } 49 | class ViewHolder{ 50 | TextView juziContent; 51 | TextView juziTitle; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/eventbus/Event.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.eventbus; 2 | 3 | import java.util.List; 4 | 5 | public class Event 6 | { 7 | /** 列表加载事件 */ 8 | public static class ItemListEvent 9 | { 10 | private List items; 11 | 12 | public ItemListEvent(List items) 13 | { 14 | this.items = items; 15 | } 16 | 17 | public List getItems() 18 | { 19 | return items; 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/eventbus/EventBusActivity.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.eventbus; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.FragmentActivity; 5 | 6 | import com.common.myutil.R; 7 | 8 | public class EventBusActivity extends FragmentActivity 9 | { 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) 12 | { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_eventbus); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/eventbus/Item.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.eventbus; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class Item 7 | { 8 | public String id; 9 | public String content; 10 | 11 | 12 | //测试数据 13 | public static List ITEMS = new ArrayList(); 14 | static 15 | { 16 | // Add 6 sample items. 17 | addItem(new Item("1", "Item 1")); 18 | addItem(new Item("2", "Item 2")); 19 | addItem(new Item("3", "Item 3")); 20 | addItem(new Item("4", "Item 4")); 21 | addItem(new Item("5", "Item 5")); 22 | addItem(new Item("6", "Item 6")); 23 | } 24 | private static void addItem(Item item) 25 | { 26 | ITEMS.add(item); 27 | } 28 | 29 | 30 | 31 | public Item(String id, String content) 32 | { 33 | this.id = id; 34 | this.content = content; 35 | } 36 | 37 | @Override 38 | public String toString() 39 | { 40 | return content; 41 | } 42 | } -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/eventbus/ItemDetailFragment.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.eventbus; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.view.LayoutInflater; 6 | import android.view.View; 7 | import android.view.ViewGroup; 8 | import android.widget.TextView; 9 | 10 | import com.common.myutil.R; 11 | 12 | 13 | public class ItemDetailFragment extends Fragment 14 | { 15 | 16 | private TextView tvDetail; 17 | 18 | @Override 19 | public void onCreate(Bundle savedInstanceState) 20 | { 21 | super.onCreate(savedInstanceState); 22 | // register 23 | EventBus.getInstance().register(this); 24 | } 25 | 26 | @Override 27 | public void onDestroy() 28 | { 29 | super.onDestroy(); 30 | // Unregister 31 | EventBus.getInstance().unregister(this); 32 | } 33 | 34 | /** List点击时会发送些事件,接收到事件后更新详情 */ 35 | public void onEventUI(Item item) 36 | { 37 | if (item != null) 38 | tvDetail.setText(item.content); 39 | } 40 | 41 | @Override 42 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 43 | Bundle savedInstanceState) 44 | { 45 | View rootView = inflater.inflate(R.layout.fragment_item_detail, 46 | container, false); 47 | tvDetail = (TextView) rootView.findViewById(R.id.item_detail); 48 | return rootView; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/eventbus/ItemListFragment.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.eventbus; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.ListFragment; 5 | import android.view.View; 6 | import android.widget.ArrayAdapter; 7 | import android.widget.ListView; 8 | 9 | 10 | public class ItemListFragment extends ListFragment 11 | { 12 | 13 | @Override 14 | public void onCreate(Bundle savedInstanceState) 15 | { 16 | super.onCreate(savedInstanceState); 17 | // Register 18 | EventBus.getInstance().register(this); 19 | } 20 | 21 | @Override 22 | public void onDestroy() 23 | { 24 | super.onDestroy(); 25 | // Unregister 26 | EventBus.getInstance().unregister(this); 27 | } 28 | 29 | @Override 30 | public void onViewCreated(View view, Bundle savedInstanceState) 31 | { 32 | super.onViewCreated(view, savedInstanceState); 33 | // 开启线程加载列表 34 | new Thread() 35 | { 36 | public void run() 37 | { 38 | try 39 | { 40 | Thread.sleep(2000); // 模拟延时 41 | // 发布事件,在后台线程发的事件 42 | EventBus.getInstance().post(new Event.ItemListEvent(Item.ITEMS)); 43 | } catch (InterruptedException e) 44 | { 45 | e.printStackTrace(); 46 | } 47 | }; 48 | }.start(); 49 | } 50 | 51 | public void onEventUI(Event.ItemListEvent event) 52 | { 53 | setListAdapter(new ArrayAdapter(getActivity(), 54 | android.R.layout.simple_list_item_activated_1, 55 | android.R.id.text1, event.getItems())); 56 | } 57 | 58 | @Override 59 | public void onListItemClick(ListView listView, View view, int position, 60 | long id) 61 | { 62 | super.onListItemClick(listView, view, position, id); 63 | EventBus.getInstance().post(getListView().getItemAtPosition(position)); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/exmple/ParcelableUser.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.exmple; 2 | 3 | import android.os.Parcel; 4 | import android.os.Parcelable; 5 | 6 | /** 7 | * 8 | * Parcelable接口一般用于intent的数据传输,而不使用在本地存储对象,因为在外界变化下,Parcelable不能保证数据的持续化 9 | * Created by wangzekeng on 2017/9/8. 10 | */ 11 | 12 | public class ParcelableUser implements Parcelable { 13 | public String name; 14 | public int age; 15 | public String sex; 16 | public ParcelableUser(){}; 17 | public ParcelableUser( String name,int age,String sex){ 18 | this.name = name; 19 | this.age = age; 20 | this.sex = sex; 21 | }; 22 | protected ParcelableUser(Parcel in) { 23 | // 读取Parcel里面数据时必须按照成员变量声明的顺序 24 | this.name = in.readString(); 25 | this.age = in.readInt(); 26 | this.sex = in.readString(); 27 | } 28 | 29 | public static final Creator CREATOR = new Creator() { 30 | @Override 31 | public ParcelableUser createFromParcel(Parcel in) { 32 | return new ParcelableUser(in); 33 | } 34 | 35 | @Override 36 | public ParcelableUser[] newArray(int size) { 37 | return new ParcelableUser[size]; 38 | } 39 | }; 40 | 41 | @Override 42 | public int describeContents() { 43 | //描述内容,没什么用 44 | return 0; 45 | } 46 | 47 | @Override 48 | public void writeToParcel(Parcel dest, int flags) { 49 | // 序列化过程:必须按成员变量声明的顺序进行封装 50 | dest.writeString(this.name); 51 | dest.writeInt(this.age); 52 | dest.writeString(this.sex); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/exmple/SerializableUser.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.exmple; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * serializable 7 | * Created by wangzekeng on 2017/9/8. 8 | */ 9 | 10 | public class SerializableUser implements Serializable{ 11 | 12 | private static final long serialVersionUID = -3302212038378807035L;//系统生成 13 | public String name; 14 | public int age; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/inject/DynamicHandler.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.inject; 2 | 3 | import com.common.myutil.utils.LogUtils; 4 | 5 | import java.lang.ref.WeakReference; 6 | import java.lang.reflect.InvocationHandler; 7 | import java.lang.reflect.Method; 8 | import java.util.HashMap; 9 | 10 | /** 11 | * Created by wangzekeng on 2017/9/18. 12 | */ 13 | 14 | public class DynamicHandler implements InvocationHandler{ 15 | 16 | private WeakReference obj; 17 | private final HashMap methodMap = new HashMap(1); 18 | 19 | 20 | public DynamicHandler(Object obj){ 21 | this.obj = new WeakReference(obj); 22 | } 23 | 24 | 25 | public void addMethod(String methodName,Method method){ 26 | methodMap.put(methodName,method); 27 | } 28 | 29 | public Object getHandler(){ 30 | return obj.get(); 31 | } 32 | 33 | public void setHandler(Object obj){ 34 | this.obj = new WeakReference(obj); 35 | } 36 | 37 | @Override 38 | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { 39 | //被调用的使用才触发,第一个参数既是代理类实例,第二个参数是被调用的方法对象 40 | // 第三个方法是调用参数。调用处理器根据这三个参数进行预处理或分派到委托类实例上发射执行 41 | Object handler = getHandler(); 42 | LogUtils.e("handler invoke"); 43 | if(handler != null) { 44 | String methodName = method.getName(); 45 | method = methodMap.get(methodName); 46 | LogUtils.e("method name:" + method.getName());//clickBtnInvoked,代理调用clickBtnInvoked 47 | if (method != null) { 48 | LogUtils.e("handler method"); 49 | return method.invoke(handler, args);//需要传入这个方法的调用者 50 | } 51 | 52 | } 53 | return null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/inject/EventBase.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.inject; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Created by wangzekeng on 2017/9/18. 10 | */ 11 | @Target(ElementType.ANNOTATION_TYPE) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface EventBase { 14 | Class listenerType(); 15 | 16 | String listenerSetter(); 17 | 18 | String methodName(); 19 | } 20 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/inject/InjectActivity.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.inject; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.view.View; 6 | import android.widget.Button; 7 | import android.widget.Toast; 8 | 9 | import com.common.myutil.R; 10 | import com.common.myutil.utils.LogUtils; 11 | 12 | public class InjectActivity extends AppCompatActivity { 13 | 14 | @Override 15 | protected void onCreate(Bundle savedInstanceState) { 16 | super.onCreate(savedInstanceState); 17 | setContentView(R.layout.activity_inject); 18 | 19 | 20 | 21 | // Button button1 = (Button) findViewById(R.id.button1); 22 | // Button button2 = (Button) findViewById(R.id.button2); 23 | // button2.setOnLongClickListener(new View.OnLongClickListener() { 24 | // @Override 25 | // public boolean onLongClick(View v) { 26 | // return false; 27 | // } 28 | // }); 29 | //绑定注解处理 30 | ViewInjectUtils.inject(this); 31 | } 32 | //注解 33 | @OnClick({R.id.button1}) 34 | public void clickBtnInvoked(View view){ 35 | switch (view.getId()){ 36 | case R.id.button1: 37 | Toast.makeText(this,"button1 is clicked!!!",Toast.LENGTH_LONG).show(); 38 | LogUtils.d("button1 is clicked!"); 39 | break; 40 | 41 | default: 42 | break; 43 | } 44 | } 45 | 46 | @OnLongClick({R.id.button2}) 47 | public boolean onLongClickInvoked(View view){ 48 | switch (view.getId()) { 49 | case R.id.button2: 50 | Toast.makeText(this, "button2 is long clicked!!!", Toast.LENGTH_LONG).show(); 51 | LogUtils.d("button2 is long clicked!"); 52 | 53 | break; 54 | } 55 | return false;//setOnLongClickListener需要返回值 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/inject/OnClick.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.inject; 2 | 3 | import android.view.View; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Created by wangzekeng on 2017/9/18. 12 | */ 13 | @Target(ElementType.METHOD) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | @EventBase(listenerType = View.OnClickListener.class,listenerSetter = "setOnClickListener",methodName = "onClick") 16 | public @interface OnClick { 17 | int[] value(); 18 | } 19 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/inject/OnLongClick.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.inject; 2 | 3 | import android.view.View; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * Created by wangzekeng on 2017/9/19. 12 | */ 13 | @Target(ElementType.METHOD) 14 | @Retention(RetentionPolicy.RUNTIME) 15 | //这里绑定的名字需要同android原来的方法名字参数一致 16 | @EventBase(listenerType = View.OnLongClickListener.class,listenerSetter = "setOnLongClickListener",methodName = "onLongClick") 17 | public @interface OnLongClick { 18 | int[] value(); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/sharepreferences/VoiceAutoPlayPreferences.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.sharepreferences; 2 | 3 | 4 | import com.common.myutil.base.BaseSharePreferences; 5 | 6 | /** 7 | * Created by wangzekeng on 2017/3/7. 8 | */ 9 | 10 | public class VoiceAutoPlayPreferences extends BaseSharePreferences { 11 | 12 | public static final String Key_AutoPlay = "autoplay"; 13 | 14 | static { 15 | fileName = "voice"; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/utils/DateUtils.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.utils; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | import java.util.Locale; 6 | /** 7 | * 日期类 8 | * Created by wangzekeng on 2017/8/27. 9 | */ 10 | public class DateUtils { 11 | /** 12 | * @param timeMillis time in milliseconds since January 1, 1970 00:00:00.0 UTC. 13 | * @return 14 | */ 15 | public static String getFriendlyTime(long timeMillis) { 16 | long distanceTimeMillis = System.currentTimeMillis() - timeMillis; 17 | if (distanceTimeMillis > 24 * 60 * 60 * 1000) {//天 18 | Date date = new Date(timeMillis); 19 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd", Locale.getDefault()); 20 | return simpleDateFormat.format(date); 21 | // return (distanceTimeMillis/(24*60*60*1000)) + "昨天"; 22 | } else if (distanceTimeMillis > 60 * 60 * 1000) {//小时 23 | return (distanceTimeMillis / (60 * 60 * 1000)) + "小时前"; 24 | } else if (distanceTimeMillis > 60 * 1000) {//分钟 25 | return (distanceTimeMillis / (60 * 1000)) + "分钟前"; 26 | } else if (distanceTimeMillis > 1000) {//秒前 27 | return (distanceTimeMillis / 1000) + "秒前"; 28 | } else { 29 | return "刚刚"; 30 | } 31 | } 32 | 33 | public static boolean isCloseEnough(long paramLong1, long paramLong2) { 34 | long l = paramLong1 - paramLong2; 35 | if (l < 0L) { 36 | l = -l; 37 | } 38 | return l < 300000L; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/utils/NumberUitls.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.utils; 2 | 3 | import java.text.DecimalFormat; 4 | 5 | /** 6 | * 数字类 7 | * Created by wangzekeng on 2017/6/21. 8 | */ 9 | 10 | public class NumberUitls { 11 | 12 | /** 13 | * 转化成以万为单位 14 | * 15 | * @param num 16 | * @return 17 | */ 18 | public static String formatWan(long num) { 19 | String s = num + ""; 20 | if (num > 10000) { 21 | DecimalFormat df = new DecimalFormat("###.00"); 22 | float f = num / 10000.0f; 23 | s = df.format(f) + "万"; 24 | } 25 | return s; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/utils/quickadapter/FNMultiItemTypeSupport.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.utils.quickadapter; 2 | 3 | public interface FNMultiItemTypeSupport { 4 | int getLayoutId(int position, T t); 5 | 6 | int getViewTypeCount(); 7 | 8 | int getItemViewType(int postion, T t); 9 | } -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/view/AnimateActivity.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.view; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | 7 | /** 8 | * Created by wangzekeng on 2017/10/9. 9 | */ 10 | 11 | public class AnimateActivity extends Activity { 12 | @Override 13 | protected void onCreate(@Nullable Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(new DemoSurfaceView(this)); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/java/com/common/myutil/view/AnimateView.java: -------------------------------------------------------------------------------- 1 | package com.common.myutil.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.view.View; 8 | 9 | /** 10 | * Created by wangzekeng on 2017/10/9. 11 | */ 12 | 13 | public class AnimateView extends View { 14 | float radius = 10; 15 | Paint paint; 16 | 17 | public AnimateView(Context context) { 18 | super(context); 19 | init(); 20 | } 21 | 22 | private void init() { 23 | paint = new Paint(); 24 | paint.setColor(Color.BLACK); 25 | paint.setStyle(Paint.Style.STROKE); 26 | } 27 | 28 | @Override 29 | protected void onDraw(Canvas canvas) { 30 | super.onDraw(canvas); 31 | canvas.translate(200,200); 32 | canvas.drawCircle(0,0,radius++,paint); 33 | if(radius > 100){ 34 | radius = 10; 35 | } 36 | invalidate();//会调用onDraw 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/res/drawable-xhdpi/beginstudy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/MyUtil/app/src/main/res/drawable-xhdpi/beginstudy.png -------------------------------------------------------------------------------- /MyUtil/app/src/main/res/drawable-xhdpi/bg_dialog_content.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/MyUtil/app/src/main/res/drawable-xhdpi/bg_dialog_content.9.png -------------------------------------------------------------------------------- /MyUtil/app/src/main/res/drawable-xhdpi/bg_dialog_title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/MyUtil/app/src/main/res/drawable-xhdpi/bg_dialog_title.png -------------------------------------------------------------------------------- /MyUtil/app/src/main/res/drawable-xhdpi/bg_edit.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/MyUtil/app/src/main/res/drawable-xhdpi/bg_edit.9.png -------------------------------------------------------------------------------- /MyUtil/app/src/main/res/drawable-xhdpi/btn_orange.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/MyUtil/app/src/main/res/drawable-xhdpi/btn_orange.9.png -------------------------------------------------------------------------------- /MyUtil/app/src/main/res/drawable-xhdpi/g_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/happyKen/commonUtil/9bde2a05dab7b8b3b6adc6336f34a3b7cf313117/MyUtil/app/src/main/res/drawable-xhdpi/g_white.png -------------------------------------------------------------------------------- /MyUtil/app/src/main/res/layout/activity_eventbus.xml: -------------------------------------------------------------------------------- 1 | 9 | 10 | 16 | 17 | 23 | 24 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/res/layout/activity_gl.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /MyUtil/app/src/main/res/layout/activity_inject.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 |