This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void shuffle(Object[] a) { | |
//判断数组 a 是否可以转为整型数组 | |
validateNotNull(a); | |
int n = a.length; | |
for (int i = 0; i < n; i++) { | |
int r = i + uniform(n-i); // between i and n-1 | |
Object temp = a[i]; | |
a[i] = a[r]; | |
a[r] = temp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Form2_FormClosing(object sender, FormClosingEventArgs e) | |
{ | |
e.Cancel = (MessageBox.Show("Sure?", | |
"Exit", | |
MessageBoxButtons.YesNo, | |
MessageBoxIcon.Question) == DialogResult.Yes); | |
DialogResult result = MessageBox.Show("提示", "确定退出吗?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); | |
if (result == DialogResult.Yes) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class Form2 : Form | |
{ | |
//唯一实例 | |
private static Form2 obj = null; | |
private Form2() | |
{ | |
//初始化控件(自动生成) | |
InitializeComponent(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OnlyYou | |
{ | |
//构造函数 | |
private OnlyYou() | |
{ | |
} | |
//注意类型是 OnlyYou,并且是静态的 | |
private static OnlyYou obj = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.查看帮助ToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.D5 | Keys.Control; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//使用之前: | |
//项目 -> 添加引用 -> 搜索 System.web 添加 | |
string str = System.Web.HttpUtility.UrlEncode("机械键盘", System.Text.Encoding.GetEncoding("GB2312")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* void deleteLast() 删除最后一个元素 | |
* void delete(int k) 删除第 k 个元素 | |
* boolean find(LinkedList list, String key) 查找链表中是否存在某个结点的值域为 key | |
* void removeAfter(Node node) 删除该结点的后续结点 | |
* void insertAfter(Node node1, Node node2) 将第二个结点放在第一个结点后面 | |
* void remove(LinkedList list, String key) 删除所有值为 key 的结点 | |
* int max(LinkedList first) 接收一个首结点,返回值最大的结点的值,为空返回 0 | |
* int max(LinkedList first) 用递归解决 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//内部类依赖于外部类,所以要先创建外部类对象 | |
//第一种方式: | |
Outter outter = new Outter(); | |
Outter.Inner inner = outter.new Inner(); //必须通过Outter对象来创建 | |
//第二种方式: | |
Outter.Inner inner1 = outter.getInnerInstance(); | |
//如果外部类是泛型类,可以这么写 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 栈的特点是后进先出,新的元素在栈顶,出栈也是从栈顶出。 | |
* 栈存放的是一个个节点,每个节点存放一个对象的引用,和一个链接。 | |
* 这个链接指向下一个节点或者 null。 | |
* 栈中的 first 变量链接第一个节点。 | |
*/ | |
import java.util.Iterator; | |
import java.util.Scanner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Stack<Integer> stack = new Stack<Integer>(); | |
while(N > 0) { | |
stack.push(N % 2); | |
N = N / 2; | |
} | |
for(int d : stack) { | |
System.out.print(d); | |
} | |
System.out.println(); |