当前位置: 首页 > news >正文

京东网站开发做网站的语言版本

京东网站开发,做网站的语言版本,备案没有商城可以做商城网站吗,沈阳哪家网站制作公司比较好文章目录day31 整数矩阵及其运算面向对象思想java异常处理java中的getter和setter方法代码day31 整数矩阵及其运算 面向对象思想 结合之前day7和day8面向过程开发#xff0c;只关注了矩阵加法和矩阵乘法的功能。而day31是面向对象开发#xff0c;一个矩阵类#xff0c;在这… 文章目录day31 整数矩阵及其运算面向对象思想java异常处理java中的getter和setter方法代码day31 整数矩阵及其运算 面向对象思想 结合之前day7和day8面向过程开发只关注了矩阵加法和矩阵乘法的功能。而day31是面向对象开发一个矩阵类在这个类对象中包含有矩阵的加法乘法获取数据等功能如add,multiply方法。同时通过getset方法来让用户通过方法获取类相关数据getData,getRows,getColumns,setValue等而非直接获取数据。在IntMatrix类方法名为add的有两个但这两个方法的区别在于传参以及返回不同这体现了方法重载。 面向对象的三大特点定义的描述来自百度 封装 1定义将数据和对数据的操作封装在一个对象内部对外部隐藏对象的实现细节保证了程序的安全性和可靠性。 2IntMatrix类就体现了封装性将数据和相关的操作封装在对象内部我们对外只提供相应饿方法如我们调用矩阵相乘就可以直接调用multiply方法即可继承 1定义通过定义父类和子类子类可以继承父类的属性和方法减少代码重复提高代码的可维护性多态 1定义同一个方法可以根据不同的对象调用不同的实现方式从而提高代码的灵活性和可扩展性。多态一般是通过继承或接口来实现的 java异常处理 在之前写哈夫曼树时已经涉及异常处理了java的异常处理方法 try-catch-finally: 将可能要出现异常的代码放入try中catch 捕获 try 中的异常并处理,不管有没有异常finally中的代码都会执行。(finally不是必须) throw: 一般是语句抛出一个异常 一般是手动抛出,并且可以抛出更为明确的异常 throws:一般是方法抛出一个异常在方法后面声明异常(表示该方法可能会产生异常) java中的getter和setter方法 一般在创建java实体类时会把类相关属性设置为私有private(这是从安全角度去考虑)想要获取或设置这些私有属性可以通过方法去获取或设置即getXXXsetXXX而不是直接去操作这一个变量。这也体现了java的一大特点封装性。 访问权限修饰符private,procted,public,default不同的访问权限访问的范围不一样从网上找了一个这样的图 在项目中使用lombok可以减少写getter/setter/toString等方法的编写 代码 package matrix; import java.util.Arrays; public class IntMatrix {int[][] data;/*** The first constructor.* param paraRows The number of rows* param paraColumns The number of columns*/public IntMatrix(int paraRows, int paraColumns){data new int[paraRows][paraColumns];}/*** The second constructor. Construct a copy of the given matrix.* param paraMatrix The given matrix.*/public IntMatrix(int[][] paraMatrix){data new int[paraMatrix.length][paraMatrix[0].length];for (int i 0; i data.length; i) {for (int j 0; j data[0].length; j) {data[i][j] paraMatrix[i][j];}}}/*** The third constructor. Construct a copy of the given matrix.* param paraMatrix The given matrix.*/public IntMatrix(IntMatrix paraMatrix) {this(paraMatrix.getData());}/*** Get identity matrix. The values at the diagonal are all 1* param paraRows* return*/public static IntMatrix getIdentityMatrix(int paraRows) {IntMatrix resultMatrix new IntMatrix(paraRows, paraRows);for (int i 0; i paraRows; i) {// According to access control, resultMatrix.data can be visitedresultMatrix.data[i][i] 1;}return resultMatrix;}/*** Overrides the method claimed in Object, the superclass of any class.* return*/Overridepublic String toString() {return Arrays.deepToString(data);}/*** Get my data. Warning, the reference to the data instead of a copy of the data is returned.* return*/public int[][] getData() {return data;}public int getRows() {return data.length;}public int getColumns() {return data[0].length;}/*** Set one the value of one element.* param paraRow The row of the element.* param paraColumn The column of the element.* param paraValue The new value.*/public void setValue(int paraRow, int paraColumn, int paraValue){data[paraRow][paraColumn] paraValue;}/*** Get the value of one element.* param paraRow The row of the element.* param paraColumn The column of the element.* return*/public int getValue(int paraRow, int paraColumn) {return data[paraRow][paraColumn];}/*** Add another matrix to me.* param paraMatrix The other matrix.* throws Exception*/public void add(IntMatrix paraMatrix) throws Exception {// Step 1. Get the data of the given matrix.int[][] tempData paraMatrix.getData();// Step 2. Size check.if (data.length ! tempData.length) {throw new Exception(Cannot add matrices. Rows not match: data.length vs. tempData.length .);}if (data[0].length ! tempData[0].length) {throw new Exception(Cannot add matrices. Rows not match: data[0].length vs. tempData[0].length .);}// Step 3. Add to me.for (int i 0; i data.length; i) {for (int j 0; j data[0].length; j) {data[i][j] tempData[i][j];}}}/*** Add two existing matrices.* param paraMatrix1 The first matrix.* param paraMatrix2 The second matrix.* return A new matrix.* throws Exception*/public static IntMatrix add(IntMatrix paraMatrix1, IntMatrix paraMatrix2) throws Exception {// Step 1. Clone the first matrix.IntMatrix resultMatrix new IntMatrix(paraMatrix1);// Step 2. Add the second one.resultMatrix.add(paraMatrix2);return resultMatrix;}/*** Multiply two existing matrices.* param paraMatrix1 The first matrix.* param paraMatrix2 The second matrix.* return A new matrix.* throws Exception*/public static IntMatrix multiply(IntMatrix paraMatrix1, IntMatrix paraMatrix2) throws Exception {// Step 1. Check size.int[][] tempData1 paraMatrix1.getData();int[][] tempData2 paraMatrix2.getData();if (tempData1[0].length ! tempData2.length) {throw new Exception(Cannot multiply matrices: tempData1[0].length vs. tempData2.length .);}// Step 2. Allocate space.int[][] resultData new int[tempData1.length][tempData2[0].length];// Step 3. Multiply.for (int i 0; i tempData1.length; i) {for (int j 0; j tempData2[0].length; j) {for (int k 0; k tempData1[0].length; k) {resultData[i][j] tempData1[i][k] * tempData2[k][j];}}}// Step 4. Construct the matrix object.IntMatrix resultMatrix new IntMatrix(resultData);return resultMatrix;}public static void main(String args[]) {IntMatrix tempMatrix1 new IntMatrix(3, 3);tempMatrix1.setValue(0, 1, 1);tempMatrix1.setValue(1, 0, 1);tempMatrix1.setValue(1, 2, 1);tempMatrix1.setValue(2, 1, 1);System.out.println(The original matrix is tempMatrix1);IntMatrix tempMatrix2 null;try {tempMatrix2 IntMatrix.multiply(tempMatrix1, tempMatrix1);} catch (Exception ee) {System.out.println(ee);}System.out.println(The square matrix is tempMatrix2);IntMatrix tempMatrix3 new IntMatrix(tempMatrix2);try {tempMatrix3.add(tempMatrix1);} catch (Exception ee) {System.out.println(ee);}System.out.println(The connectivity matrix is tempMatrix3);} }
http://www.w-s-a.com/news/373689/

相关文章:

  • 山西省住房和城乡建设厅网站报名wordpress添加标签插件
  • 网站怎么自己做外贸网站案例
  • 做网站的优势公司网站怎么做站外链接
  • 海城网站制作建设精准营销的营销方式
  • 北京短视频拍摄公司重庆网站seo推广公司
  • 广州免费推广网站建设4399网页游戏大全
  • 网站的构架与组成建站公司兴田德润
  • php网站部署步骤邯郸哪有做网站的
  • 做设计什么设计比较好的网站南充市住房和城乡建设局考试网站
  • 郑州做系统集成的公司网站龙岩
  • 厦门SEO_厦门网站建设网络营销课程视频
  • vs 2015 网站开发开网店在线咨询
  • 前端如何优化网站性能大学学校类网站设计
  • 中国铁路建设投资公司网站熊学军中国it外包公司排名前50
  • 房产网站的建设广州推广排名
  • 湟源县网站建设wordpress删除未分类
  • 营销型网站开发推广厦门百度seo公司
  • 遵义网站开发培训上海中高风险地区名单最新
  • 禹州市门户网站建设做网站可以申请个体户么
  • 大良营销网站建设效果彩票网站搭建 做网站
  • 做网站的公司为什么人少了在中国如何推广外贸平台
  • 盘锦网站制作工业电商网站怎么配色
  • 白云企业网站建设seo排名点击软件
  • wordpress跨站脚本攻击漏洞国外注册的域名国内能用吗
  • 西部数码网站管理助手2工信部资质查询网站
  • 公司网站哪个建的好吉林网站制作
  • 视频网站怎么引流wordpress私人玩物
  • 我的家乡湛江网站设计新钥匙网站建设
  • 辽宁网站推广爱前端wordpress5.0.3主题
  • python怎么做网站贵阳网站制作