java金融与数学
1、commons-math/commons-lang-math
以上两个包是apache下的,前者比后者的功能强大,后者有的功能前都有,后者主要解决平时程序中的一些基本的数学计算,主要是范围判断(*Range),随机数生成(JVMRandom,RandomUtils),分数处理(Fraction),数字转化、大小判断(NumberUtils)等。前者可以处理更复杂的数据分析(org.apache.commons.math.analysis)、复数(org.apache.commons.math.complex)、分布式处理(org.apache.commons.math.distribution)、数据预测估计(org.apache.commons.math.estimation)、分数、遗传学(org.apache.commons.math.genetics)、几何图形(org.apache.commons.math.geometry)、线性代数(org.apache.commons.math.linear)、优化(org.apache.commons.math.optimization)、统计(org.apache.commons.math.stat),传换(org.apache.commons.math.transform)、还有一些常用工具类(org.apache.commons.math.util)。
例子:求两直线的交点,第一条两个端点分别为(0,0)、(1,1),另一条两个端点分别(1,0)、(0,1)。
思路:再条直线的交点,实际就是一个二元一次方程的解。方程的解实际可转化为线性代数中的矩阵。如3x+y=4和x+2y=3这个二元一次方程。转为矩阵为:
现在就可以用上面包org.apache.commons.math.geometry的类RealMatrix计算。
代码:
double[][] coefficientsData = { { 3, 1 }, { 1, 2 } };
RealMatrix coefficients = new RealMatrixImpl(coefficientsData);
double[] constants = { 4, 3 };
double[] solution = coefficients.solve(constants);
System.out.println("它们的交点是:x=" + solution[0] + ";y=" + solution[1]);
总结:如果要用到相应功能的(比如方差variance是在统计stat包里),可查看对应的包中的API和官方例子怎么用。
2、jsjava
这个插件,几乎用js语言重写了apache commons lang中的功能,其实是上面commons-math的js版(jsjava-math.js),主要有
1) jsjava-core.js : include jsjava core classes
2) jsjava-ajax.js : include jsjava ajax classes
3) jsjava-anim.js : include jsjava animation classes
4) jsjava-math.js : include jsjava math classes
5) jsjava-blog.js : include jsjava blog classes
6) jsjava-comp.js : include jsjava components classes
7) jsjava-info.js : include jsjava information classes
相关文档:
原帖及讨论:http://bbs.bc-cn.net/dispbbs.asp?boardid=12&id=140292
* 最近因为开发活动需要,用上了Eclipse,并要求使用精简版的SQL数据库(即SQL Server 2005)来进行开发项目 *
1.准备工作: 准备相关的软件(Eclipse除外,开源软件可以从官网下载)
<1> .Microsoft   ......
package test;
/**
*
* @author openpk
*/
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
public class Main {
public static void main(String[] args) {
// 线程池
ExecutorService exec = Executors ......
=====suppose such a method:
public static void openFile(String fileName, PrintWriter stream) throws FileNotFoundException
{
stream = new PrintWriter(fileName);
}
=====then we want to use it this way:
PrintWriter toFile = null;
try
{
openFile("data.txt", t ......
JAVA相关基础知识
1、面向对象的特征有哪些方面
1.抽象:
抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面。抽象并不打算了解全部问题,而只是选择其中的一部分,暂时不用部分细节。抽象包括两个方面,一是过程抽象,二是数据抽象。
2.继承:
继承是一种联结类的层次模型,并 ......
KeywordFilter.java:
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class KeywordFilter
{
private static Pattern pattern = null;
private static KeywordFilter filter = new KeywordF ......