java中final 定义常量有两种方式,一种是静态常量,一种是实例常量,下面分别介绍静态常量的定义又可以分两种情况:一种是定义时赋值,一种是静态方法块中赋值定义时赋值,如下代码:/** * Created by Jokul on 2018/1/17. */public class FinalTest { private static final String A = &
分类:
编程语言 时间:
2018-01-20 22:47:57
阅读次数:
198
【根据生日获取年龄】 /** * 根据生日获取年龄 * @param birthday * @return * @throws Exception */ private static int getAgeByBirth(Date birthday) throws Exception { int ag ...
分类:
其他好文 时间:
2018-01-19 11:29:13
阅读次数:
117
当需要共享的变量很多时,使用static变量占用内存的时间过长,在类的整个生命周期。 而对象只是存在于对象的整个生命周期。 //饿汉式 class Single//类一加载,对象就已经存在了。 { private static Single s = new Single(); private Sin ...
分类:
编程语言 时间:
2018-01-17 23:37:11
阅读次数:
387
1 package com.jdk7.chapter2.singleton; 2 3 public class SingletonA { 4 //java虚拟机会加载静态变量 5 private static int id = 1; 6 private static SingletonA insta... ...
分类:
其他好文 时间:
2018-01-17 00:27:06
阅读次数:
145
两种设计模式 1.单例模式 模式的保证步骤:单例(是说在一个类中只能有一个对象)三条件 1.1类构造设置私有 private Play() { } 1.2 定义一个私有的静态的 类类型 变量 private static Play play; 1.3 定义共有的 静态的 并且 返回值类型为 类类型 ...
分类:
其他好文 时间:
2018-01-16 18:42:11
阅读次数:
228
private static void RecursionAlgorithm(int end) { int a = 1, b = 0, c = b; while (true) { c = a + b; a = b; b = c;... ...
分类:
编程语言 时间:
2018-01-16 18:04:46
阅读次数:
164
public class 连续子数组的最大和{ // 时间复杂度为O(n) private static int getSubMaxSum(int[] array) { if (array == null || array.length == 0) { return 0; } int sum = 0 ...
分类:
编程语言 时间:
2018-01-15 16:29:59
阅读次数:
118
/// /// 获取文件的MD5码 /// /// 文件路径 /// MD5码 private static string GetFileMD5(string filePath) { try { var file = ne... ...
分类:
其他好文 时间:
2018-01-15 14:47:56
阅读次数:
113
// 使用堆排序实现 其时间复杂度为O(nlgn) private static void buildMaxHeap(int[] input, int end) { // 从非叶子节点开始进行 for (int i = (end - 1) / 2; i >= 0; i--) { // 当前节点 cu ...
分类:
编程语言 时间:
2018-01-14 14:30:29
阅读次数:
160
资料查找https://www.cnblogs.com/tdws/p/5836122.html https://www.cnblogs.com/lori/p/5794454.html private static readonly ConnectionMultiplexer _sentinel; s ...