自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

\s

edd

  • 博客(303)
  • 收藏
  • 关注

转载 without synchronized keyword

package HeadFirstJava;class BankAccount { private int balance = 100; public int getBalance() { return balance; } public void withdraw(int amount) { balance = bal

2015-07-30 10:33:51 608

转载 synchronized keyword DEMO

package HeadFirstJava;class BankAccount { private int balance = 100; public int getBalance() { return balance; } public void withdraw(int amount) { balance = bal

2015-07-30 10:32:31 617

转载 start 2 threads

package HeadFirstJava;public class RunThreads implements Runnable { public static void main(String[] args) { RunThreads runner = new RunThreads(); // make a Runnable object Thre

2015-07-30 09:48:37 501

转载 use sleep() to gain thread predictability

package HeadFirstJava;class MyRunnable implements Runnable { public void run() { go(); } public void go() { try { Thread.sleep(2000); } catch(Interrup

2015-07-30 09:37:27 477

转载 thread unpredictability

package HeadFirstJava;class MyRunnable implements Runnable { public void run() { go(); } public void go() { doMore(); } public void doMore() { System.out.

2015-07-30 09:24:16 474

转载 String::split() DEMO

package HeadFirstJava;public class TestJava { public static void main(String[] args) { String toTest = "What is blue + yellow?/green"; String[] result = toTest.split("/");

2015-07-29 10:08:15 394

转载 read text file DEMO

package HeadFirstJava;import java.io.*;class ReadAFile { public static void main(String[] args) { try { File myFile = new File("MyText.txt"); FileReader fileRea

2015-07-29 10:01:08 426

转载 write to text file DEMO

package HeadFirstJava;import java.io.*;class WriteFile { public static void main(String[] args) { try { FileWriter writer = new FileWriter("Foo.txt"); writer.wr

2015-07-29 09:35:47 569

转载 serialization DEMO

package HeadFirstJava;import java.io.*;@SuppressWarnings("serial")public class Box implements Serializable { @SuppressWarnings("unused") private int width; @SuppressWarnings("unused")

2015-07-29 09:21:50 382

转载 JTextArea DEMO

package HeadFirstJava;import javax.swing.*;import java.awt.*;import java.awt.event.*;public class TextArea1 implements ActionListener { JTextArea text; public static void main(Strin

2015-07-29 08:36:24 676

转载 box layout DEMO

package HeadFirstJava;import javax.swing.*;import java.awt.*;public class Panel1 { public static void main(String[] args) { Panel1 gui = new Panel1(); gui.go(); } publi

2015-07-29 08:19:10 382

转载 flow layout DEMO

package HeadFirstJava;import javax.swing.*;import java.awt.*;public class Panel1 { public static void main(String[] args) { Panel1 gui = new Panel1(); gui.go(); } publi

2015-07-29 08:09:08 554

转载 Border Layout demo

package HeadFirstJava;import javax.swing.*;import java.awt.*;public class Button { public static void main(String[] args) { Button gui = new Button(); gui.go(); } publi

2015-07-28 11:58:15 805

转载 button with a big font

package HeadFirstJava;import javax.swing.*;import java.awt.*;public class Button { public static void main(String[] args) { Button gui = new Button(); gui.go(); } publi

2015-07-28 11:48:29 475

转载 BorderLayout manager DEMO

package HeadFirstJava;import javax.swing.*;import java.awt.*;public class Button { public static void main(String[] args) { Button gui = new Button(); gui.go(); } publi

2015-07-28 11:40:23 397

转载 event source => listener

package HeadFirstJava;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.*;public class SimpleGui { JButton button; public

2015-07-28 11:20:08 697

转载 2 event sources & inner class

import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.*;@SuppressWarnings("serial")class MyDrawPanel extends JPanel { public void paint

2015-07-28 10:00:48 412

转载 draw something in Java DEMO

import java.awt.*;import javax.swing.*;@SuppressWarnings("serial")class MyDrawPanel extends JPanel { public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D) g; G

2015-07-28 09:27:59 609

转载 event handling in Java

import javax.swing.*;import java.awt.event.*;public class SimpleGui implements ActionListener { JButton button; public static void main(String[] args) { SimpleGui gui = new Si

2015-07-28 09:03:48 717 1

转载 Java simple GUI DEMO

import javax.swing.*;public class SimpleGui { public static void main(String[] args) { JFrame frame = new JFrame(); JButton button = new JButton("click me"); fra

2015-07-28 08:50:15 577

原创 Java calendar DEMO

import java.util.Calendar;public class Test { public static void main(String[] args) { Calendar c = Calendar.getInstance(); System.out.println(c.getTime()); }}Mon Jul 27 1

2015-07-27 12:08:23 437

原创 final in Java DEMO

class Dog { int size;}public class Test { public static void main(String[] args) { final Dog dog = new Dog(); dog.size = 100; System.out.println(dog.size);

2015-07-27 11:57:58 365

转载 OO in java DEMO

// quote from "Head First Java, 2e"public class GameLauncher { public static void main(String[] args) { GuessGame game = new GuessGame(); game.startGame(); }}public class G

2015-07-27 09:25:47 338

转载 Java DEMO

// quote from "Head First Java, 2e"// FileName: DogTestDrive.javaclass Dog { int size; String bred; String name; void bark() { System.out.println("Ruff! Ruff!"); }}

2015-07-27 09:00:53 405

转载 Optimal Substructure DEMO(without memorization: overlapping subproblems)

# quote from 'introduction to computation and programming # using Python, revised, MIT press class Item(object): def __init__(self, n, v, w): self.name = n self.value

2015-07-26 13:18:37 459

转载 Dynamic Programming(DP) (Optimal substructure + overlapping subproblems(memorization))DEMO

# quote from 'introduction to computation and programming # using Python, revised, MIT press class Item(object): def __init__(self, n, v, w): self.name = n self.value

2015-07-26 13:14:36 729

转载 memorization DEMO

# quote from 'introduction to computation and programming # using Python, revised, MIT press def fastFib(n, memo = {}): """Assumes n is an int >= 0, memo used only by recursive calls

2015-07-26 12:44:57 699

转载 BFS & DFS DEMO

# quote from 'introduction to computation and programming # using Python, revised, MIT press class Node(object): def __init__(self, name): """Assumes name is a string""" se

2015-07-26 12:19:28 391

转载 greedy algorithm DEMO

# quote from 'introduction to computation and programming # using Python, revised, MIT press class Item(object): def __init__(self, n, v, w): self.name = n self.value = flo

2015-07-26 10:57:37 518

转载 distance

# quote from 'introduction to computation and programming # using Python, revised, MIT press import pylabdef minkowskiDist(v1, v2, p): """Assumes v1 and v2 are equal-length arrays of numbe

2015-07-25 07:45:04 501

转载 Mortgage DEMO

# quote from 'introduction to computation and programming # using Python, revised, MIT press import pylabdef findPayment(loan, r, m): """Assumes: loan and r are floats, m an int Ret

2015-07-24 13:01:27 592

转载 Exponential Fitting

# quote from 'introduction to computation and programming # using Python, revised, MIT press import pylabimport math#define an arbitrary exponential functiondef f(x): return 3*(2**(1.2*x

2015-07-24 10:00:01 579

转载 Coefficient of Determination(R Squared)(How to determine goodness of fit)?

# quote from 'introduction to computation and programming # using Python, revised, MIT press import pylabdef getTrajectoryData(fileName): dataFile = open(fileName, 'r') distances = []

2015-07-24 09:38:38 881

转载 best fit line

#quote from 'introduction to computation and programming   #using Python, revised, MIT pressimport pylabdef getData(fileName): dataFile = open(fileName, 'r') distances = [] masses = [

2015-07-24 08:30:54 1302

转载 inner class DEMO(quote from Head First Java 2e)

import javax.swing.*;import java.awt.*;public class SimpleAnimation { int x = 70; int y = 70; public static void main(String[] args) { SimpleAnimation gui = new SimpleAnima

2015-07-23 11:54:21 441

转载 2 event source & inner class DEMO(quote from Head First Java 2e)

import java.awt.BorderLayout;import java.awt.Color;import java.awt.Graphics;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.

2015-07-23 11:21:01 376

转载 Simple Java GUI DEMO(quote from head first java 2e)

import javax.swing.*;import java.awt.*;import java.awt.event.*;@SuppressWarnings("serial")class MyDrawPanel extends JPanel { public void paintComponent(Graphics g) { g.fillRect(0, 0

2015-07-23 10:44:22 557

转载 trace walk DEMO

#quote from 'introduction to computation and programming #using Python, revised, MIT press'import randomimport pylabdef stdDev(X): mean = sum(X)/len(X) tot = 0.0 for x in X: t

2015-07-20 10:38:55 396

转载 get final location DEMO

#quote from 'introduction to computation and programming #using Python, revised, MIT press'import randomimport pylabdef stdDev(X): mean = sum(X)/len(X) tot = 0.0 for x in X: t

2015-07-20 10:29:31 526

转载 random walk for different types of Drunks

#quote from 'introduction to computation and programming #using Python, revised, MIT press'import randomimport pylabdef stdDev(X): mean = sum(X)/len(X) tot = 0.0 for x in X: t

2015-07-20 10:15:36 554

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除