易截截图软件、单文件、免安装、纯绿色、仅160KB

JAVA实现矩阵基本操作

niMatrix.java
package com.nileader.matrix;
/*
* Copyright (C) 2009 nileader
* when copyed ,please marked from http://nileader.jimdo.com
*/
class niMatrix {

private double prop[][]; // 用二维数组代表这个矩阵
private int rows; //矩阵的行数
private int cols; //矩阵的列数
/*
* setter and getter
*/
public double[][] getProp() {
return prop;
}
public void setProp(double[][] prop) {
this.prop = prop;
}
public int getRows() {
return rows;
}
public int getCols() {
return cols;
}
public void setRows(int rows) {
this.rows = rows;
}
public void setCols(int cols) {
this.cols = cols;
}


/*
* 构造方法
*/
public niMatrix(int rows,int cols)
{
this.setRows(rows);
this.setCols(cols);
}

// execute method
/*
* 输出矩阵的数值
*/
public void outputVal()
{
for(int i=0 ; i<this.getRows() ; i++)
{
for(int j=0 ; j < this.getCols() ; j++)
{
System.out.print(this.getProp()[i][j]+" ");
}
System.out.println("");
}
}



/*
* desc 加减法操作
*@pram op (add/sub/mul)
*/
public void operate(String op,niMatrix NM)
{

//判断数据有效性
if(this.getRows() != NM.getRows() || this.getCols() != NM.getCols() )
{
System.out.println("无法计算");
System.out.println("注意,矩阵加减法必须行列一样,请再输入一个"+rows+"行"+cols+"列的矩阵");
System.exit(0);
}
//执行加法操作
if( "add".equalsIgnoreCase( op ) )
{
double tmp[][] = new double[this.getRows()][this.getCols()]; //暂时保存结果
for(int i =0 ; i < this.getRows(); i ++)
for(int j = 0; j < this.getCols() ; j++)
{
tmp[i][j] = this.getProp()[i][j] + NM.getProp()[i][j];
}
this.setProp(tmp); //放入最终结果
}

//执行减法操作
if( "sub".equalsIgnoreCase( op ) )
{
double tmp[


相关文档:

Java Logger(java日志)


目录
1. 简介
2. 安装
3. log4j基本概念
3.1. Logger
3.2. Appender
3.2.1. 使用ConsoleAppender
3.2.2. 使用FileAppender
3.2.3. 使用WriterAppender
3.3. Layout
3.4. 基本示例
3.4.1. SimpleLayout和FileAppender
3.4.2. HTMLLayout和WriterAppender
3.4.3. PatternLayout和ConsoleAppender
4. 使用外部 ......

JAVA:用多线程实现时间的动态显示

import java.awt.*;
import javax.swing.*;
import java.util.Date;
import java.awt.*;
class Time extends JFrame implements Runnable{//实现接口
Thread clockThread;
   JLabel jLabel=new JLabel();
   public Time()
   {
   Container con=this.getContentPane() ......

JAVA操作XML的完整例子

这是一个用JAVA W3C DOM 进行XML操作的例子,包含了查询、增加、修改、删除、保存的基本操作。较完整的描述了一个XML的整个操作流程。适合刚入门JAVA XML操作的朋友参考和学习。
假设有XML文件:test1.xml
<?xml version="1.0" encoding="UTF-8"?>
<books>
 <book>
  < ......

JAVA程序员面试之葵花宝典

JAVA程序员面试之葵花宝典
1、面向对象的特征有哪些方面
1.抽象:抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面。抽象并不打算了解全部问题,而只是选择其中的一部分,暂时不用部分细节。抽象包括两个方面,一是过程抽象,二是数据抽象。
2.继承:继承是一种联结类的层次模 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号