201771010141 周强《面向对象程序设计(java)》第十三周学习总结

实验目的与要求

(1) 掌握事件处理的基本原理,理解其用途;

(2) 掌握AWT事件模型的工作机制;

(3) 掌握事件处理的基本编程模型;

(4) 了解GUI界面组件观感设置方法;

(5) 掌握WindowAdapter类、AbstractAction类的用法;

(6) 掌握GUI程序中鼠标事件处理技术。

实验内容和步骤

实验1: 导入第11章示例程序,测试程序并进行代码注释。

测试程序1:

l 在elipse IDE中调试运行教材443页-444页程序11-1,结合程序运行结果理解程序;

l 在事件处理相关代码处添加注释;

l 用lambda表达式简化程序;

l 掌握JButton组件的基本API;

l 掌握Java中事件处理的基本编程模型。

package button;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
* 带按钮面板的框架
*/
public class ButtonFrame extends JFrame
{
private JPanel buttonPanel;//定义JPanel属性
private static final int DEFAULT_WIDTH = 600;
private static final int DEFAULT_HEIGHT = 400;

public ButtonFrame()
{
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);//通过setSize更改了宽度和高度的属性值

//创建按钮 生成了三个按钮对象,显示在窗口对象上的title文本
JButton yellowButton = new JButton("Yellow");
JButton blueButton = new JButton("Blue");
JButton redButton = new JButton("Red");

buttonPanel = new JPanel();//使new JPanel指向对象buttonPanel

//向面板添加按钮 通过add方法添加三个按钮组件
buttonPanel.add(yellowButton);
buttonPanel.add(blueButton);
buttonPanel.add(redButton);

// 将面板添加到帧
add(buttonPanel);

// 创建按钮动作
ColorAction yellowAction = new ColorAction(Color.YELLOW);
ColorAction blueAction = new ColorAction(Color.BLUE);
ColorAction redAction = new ColorAction(Color.RED);

//用按钮关联动作 监听器对象与组件之间的注册机制
yellowButton.addActionListener(yellowAction);
blueButton.addActionListener(blueAction);
redButton.addActionListener(redAction);
}

/**
* 设置面板背景颜色的动作侦听器。
*/
private class ColorAction implements ActionListener
//ColorAction类后面实现了一个监听器接口类ActionListener
{
private Color backgroundColor;

public ColorAction(Color c)
{
backgroundColor = c;
}

public void actionPerformed(ActionEvent event)
{
buttonPanel.setBackground(backgroundColor);
}
}
}

package button;

import java.awt.*;
import javax.swing.*;

/**
* @version 1.34 2015-06-12
* @author Cay Horstmann
*/
public class ButtonTest
{
public static void main(String[] args)//String类代表字符串。Java 程序中的所有字符串字面值(如 "abc" )都作为此类的实例实现。
{
EventQueue.invokeLater(() -> {
JFrame frame = new ButtonFrame();//生成ButtonFrame对象
frame.setTitle("ButtonTest");//设置组建的自定义标题测试按钮
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置默认的关闭操作,参数在关闭动作时退出
frame.setVisible(true);//一个图形界面默认都是不可见的,setVisible把图形界面设置为可见
});
}
}

ButtonTest

package button;

import java.awt.*;
import java.awt.event.*;
import java.nio.charset.CodingErrorAction;
import java.util.Collection;

import javax.swing.*;

/**
* 带按钮面板的框架
*/
@SuppressWarnings("serial")
public class ButtonFrame extends JFrame {
private JPanel buttonPanel;// 定义JPanel属性
private static final int DEFAULT_WIDTH = 600;
private static final int DEFAULT_HEIGHT = 400;

public ButtonFrame() {
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);// 通过setSize更改了宽度和高度的属性值
buttonPanel = new JPanel();// 使new JPanel指向对象buttonPanel

// 将面板添加到帧
add(buttonPanel);
makeButton1("Yellow", Color.yellow);
makeButton1("White", Color.white);
makeButton1("Black", Color.black);
makeButton1("Green", Color.green);
makeButton1("Pink", Color.pink);
makeButton1("Blue", Color.blue);
makeButton1("Gray", Color.gray);
makeButton1("Red", Color.red);
}

public void makeButton1(String name, Color backgroundColor) {
JButton button = new JButton(name);
buttonPanel.add(button);
button.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {
buttonPanel.setBackground(backgroundColor);
}
});

}
}

测试程序2

l 在elipse IDE中调试运行教材449页程序11-2,结合程序运行结果理解程序;

l 在组件观感设置代码处添加注释;

l 了解GUI程序中观感的设置方法

package plaf;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.SwingUtilities;

import javax.swing.UIManager;

/**带有按钮面板的框架,用于改变外观

 * A frame with a button panel for changing look-and-feel

 */

public class PlafFrame extends JFrame

{

   private JPanel buttonPanel;

   public PlafFrame()

   {

      buttonPanel = new JPanel();

//获得一个用于描述已安装的观感的对象数组

      UIManager.LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();

      for (UIManager.LookAndFeelInfo info : infos)

          //返回观感的显示名称

         makeButton(info.getName(), info.getClassName());

      //返回观感实现类的名称

      add(buttonPanel);

      pack();

      //调整此窗口的大小,以适合其子组件的首选大小和布局。

   }

   /**

    * Makes a button to change the pluggable look-and-feel.

    * @param name the button name

    * @param className the name of the look-and-feel class

    */

   private void makeButton(String name, String className)

   {

      // 向面板添加按钮

      JButton button = new JButton(name);

      buttonPanel.add(button);

      // 设定按钮动作

      button.addActionListener(event -> {

         // 按钮动作:切换到新的外观

         try

         {

            UIManager.setLookAndFeel(className);

            //className - 指定实现外观的类名称的字符串

            // Swing方法的集合

            SwingUtilities.updateComponentTreeUI(this);

            //简单的外观更改:将树结构中的每个节点转到 updateUI() -- 也就是说,通过当前外观初始化其 UI 属性。

            pack();

         }

         catch (Exception e)//抛出异常

         //Exception 类及其子类是 Throwable 的一种形式,它指出了合理的应用程序想要捕获的条件。

         {

            e.printStackTrace();

            //Exception 类及其子类是 Throwable 的一种形式,它指出了合理的应用程序想要捕获的条件。

         }

      });

   }

}

package plaf;

import java.awt.*;

import javax.swing.*;

/**

 * @version 1.32 2015-06-12

 * @author Cay Horstmann

 */

public class PlafTest

{

   public static void main(String[] args)

   {

       //lambda表达式

      EventQueue.invokeLater(() -> {

         JFrame frame = new PlafFrame();

         frame.setTitle("PlafTest");

         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

         //退出应用程序默认窗口关闭操作

         frame.setVisible(true);

      });

   }

}

 

package button;

import java.awt.*;

import javax.swing.*;

/**

 * @version 1.34 2015-06-12

 * @author Cay Horstmann

 */

public class ButtonTest

{

   public static void main(String[] args)

   {

       //lambda表达式

      EventQueue.invokeLater(() -> {

         JFrame frame = new ButtonFrame();

         frame.setTitle("ButtonTest");

         //setTitle表示将此窗体的标题设置为制定的字符串

         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

         //根据参数的值显示或隐藏窗口

         frame.setVisible(true);

      });

   }

}

测试程序3:

l 在elipse IDE中调试运行教材457页-458页程序11-3,结合程序运行结果理解程序;

l 掌握AbstractAction类及其动作对象;

l 掌握GUI程序中按钮、键盘动作映射到动作对象的方法。

package action;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* 具有显示颜色变化动作的面板的框架
*/
public class ActionFrame extends JFrame
{
private JPanel buttonPanel;
private static final int DEFAULT_WIDTH = 300;
private static final int DEFAULT_HEIGHT = 200;

public ActionFrame()
{
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
// 设置默认宽度和高度
buttonPanel = new JPanel();
// 将类的实例域中的JPanel面板对象实例化
Action yellowAction = new ColorAction("Yellow", new ImageIcon("yellow-ball.gif"),
Color.YELLOW);
// 创建一个自己定义的ColorAction对象yellowAction
Action blueAction = new ColorAction("Blue", new ImageIcon("blue-ball.gif"), Color.BLUE);
Action redAction = new ColorAction("Red", new ImageIcon("red-ball.gif"), Color.RED);

//创建一个按钮,其属性从所提供的 Action中获取
buttonPanel.add(new JButton(yellowAction));
buttonPanel.add(new JButton(blueAction));
buttonPanel.add(new JButton(redAction));

//我们将这个添加好按钮的面板添加到原框架中
add(buttonPanel);

//我们将JPanel对象的InputMap设置为第二种输入映射,并创建该对象
InputMap imap = buttonPanel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
imap.put(KeyStroke.getKeyStroke("ctrl Y"), "panel.yellow");
imap.put(KeyStroke.getKeyStroke("ctrl B"), "panel.blue");
imap.put(KeyStroke.getKeyStroke("ctrl R"), "panel.red");
// 在imap中通过调用击键类KeyStroke的静态方法设置击键输入ctrl+Y的组合
// 第二个参数是一个标志参数,将这对参数用键值对的形式存入imap

// 将imap中标记参数对应的击键组合和相应的Action组合起来
ActionMap amap = buttonPanel.getActionMap();
amap.put("panel.yellow", yellowAction);
amap.put("panel.blue", blueAction);
amap.put("panel.red", redAction);
}

public class ColorAction extends AbstractAction
{
/**
* 构造颜色动作。
* @param name the name to show on the button
* @param icon the icon to display on the button
* @param c the background color
*/
public ColorAction(String name, Icon icon, Color c)
{
putValue(Action.NAME, name);
putValue(Action.SMALL_ICON, icon);
putValue(Action.SHORT_DESCRIPTION, "Set panel color to " + name.toLowerCase());
putValue("color", c);
//在构造器中设置一些键值对映射,这些设置的属性将会被JPanel读取
}

/**
* 当按钮点击或击键的时候,会自动的调用actionPerformed方法
*/
public void actionPerformed(ActionEvent event)
{
Color c = (Color) getValue("color");
buttonPanel.setBackground(c);
// 调用setBackground方法,设置背景颜色
}
}
}

package action;

import java.awt.*;
import javax.swing.*;
/**
* @version 1.34 2015-06-12
* @author Cay Horstmann
*/

import plaf.PlafFrame;
public class ActionTest
{
public static void main(String[] args)
{
EventQueue.invokeLater(() -> {
JFrame frame = new ActionFrame();//生成ActionFrame对象
frame.setTitle("ActionTest");//设置组建的自定义标题测试按钮
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置默认的关闭操作,参数在关闭动作时退出
frame.setVisible(true);//一个图形界面默认都是不可见的,setVisible把图形界面设置为可见
});
}
}

ActionTest

测试程序4:

l  在elipse IDE中调试运行教材462页程序11-4、11-5,结合程序运行结果理解程序;

l  掌握GUI程序中鼠标事件处理技术。

package mouse;

import java.awt.*;

import java.awt.event.*;

import java.awt.geom.*;

import java.util.*;

import javax.swing.*;

/**

 * A component with mouse operations for adding and removing squares.

 */

public class MouseComponent extends JComponent

{

   private static final int DEFAULT_WIDTH = 300;

   private static final int DEFAULT_HEIGHT = 200;

   private static final int SIDELENGTH = 10;

   private ArrayList<Rectangle2D> squares;

   private Rectangle2D current;

   // 包含鼠标光标的正方形

   public MouseComponent()

   {

      squares = new ArrayList<>();

      current = null;

      addMouseListener(new MouseHandler());

      addMouseMotionListener(new MouseMotionHandler());

   }

   public Dimension getPreferredSize() { return new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT); }  

   

   public void paintComponent(Graphics g)

   {

      Graphics2D g2 = (Graphics2D) g;

      // 画所有正方形

      for (Rectangle2D r : squares)

         g2.draw(r);

   }

   /**

    * Finds the first square containing a point.

    * @param p a point

    * @return the first square that contains p

    */

   public Rectangle2D find(Point2D p)

   {

      for (Rectangle2D r : squares)

      {

         if (r.contains(p)) return r;

      }

      return null;

   }

   /**

    * Adds a square to the collection.

    * @param p the center of the square

    */

   public void add(Point2D p)//Point2D 类定义表示 (x,y) 坐标空间中位置的点。

   {

      double x = p.getX();

      //以 double 精度返回此 Point2D 的 X 坐标

      double y = p.getY();

      //以 double 精度返回此 Point2D 的 Y 坐标。

      current = new Rectangle2D.Double(x - SIDELENGTH / 2, y - SIDELENGTH / 2, SIDELENGTH,

            SIDELENGTH);

      //Rectangle2D 类描述通过位置 (x,y) 和尺寸 (w x h) 定义的矩形。

      squares.add(current);

      repaint();//重绘此组件。

   }

   /**

    * 从集合中移除正方形

    * @param s the square to remove

    */

   public void remove(Rectangle2D s)

   {

      if (s == nullreturn;

      if (s == current) current = null;

      squares.remove(s);

      repaint();

   }

   private class MouseHandler extends MouseAdapter//接收鼠标事件的抽象适配器类

   {

       //鼠标按键在组件上按下时调用。

      public void mousePressed(MouseEvent event)

      {

         // 如果光标不在正方形内添加一个新的正方形

         current = find(event.getPoint());

         if (current == null) add(event.getPoint());

      }

//鼠标按键在组件上单击(按下并释放)时调用。

      public void mouseClicked(MouseEvent event)

      {

         // 如果双击,删除当前正方形

         current = find(event.getPoint());

         if (current != null && event.getClickCount() >= 2) remove(current);

      }

   }

   private class MouseMotionHandler implements MouseMotionListener

   {

      public void mouseMoved(MouseEvent event)

      {

         // 如果光标在内部,请将其设置为十字准线

         //一个矩形

         if (find(event.getPoint()) == null) setCursor(Cursor.getDefaultCursor());

         else setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

      }

      public void mouseDragged(MouseEvent event)

      {

         if (current != null)

         {

            int x = event.getX();

            int y = event.getY();

            // 拖住当前矩形,使其居中于 (x, y)

            current.setFrame(x - SIDELENGTH / 2, y - SIDELENGTH / 2, SIDELENGTH, SIDELENGTH);

            repaint();

         }

      }

   }  

}

package mouse;

import javax.swing.*;

//提供一组“轻量级”(全部是 Java 语言)组件,尽量让这些组件在所有平台上的工作方式都相同。

/**

 * 包含用于测试鼠标操作的面板的框架。

 */

public class MouseFrame extends JFrame//继承

{

   public MouseFrame()

   {

      add(new MouseComponent());//将指定组件追加到此容器的尾部

      pack();//调整此窗口的大小,以适合其子组件的首选大小和布局

   }

}

package mouse;

import java.awt.*;

import javax.swing.*;

/**

 * @version 1.34 2015-06-12

 * @author Cay Horstmann

 */

public class MouseTest

{

   public static void main(String[] args)

   {

      EventQueue.invokeLater(() -> {

         JFrame frame = new MouseFrame();

         frame.setTitle("MouseTest");//设件自定义的鼠标按钮组建

         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

         frame.setVisible(true);

      });

   }

}

实验2:结对编程练习

利用班级名单文件、文本框和按钮组件,设计一个有如下界面(图1)的点名器,要求用户点击开始按钮后在文本输入框随机显示2017级网络与信息安全班同学姓名,如图2所示,点击停止按钮后,文本输入框不再变换同学姓名,此同学则是被点到的同学姓名。

点名器启动界面

点名器点名界面

代码:

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
public class Fire {
JFrame rFrame=new JFrame("随机点名器");
//名字
String[] stuName={"王之泰","王颖奇","苏浪浪","王斌龙","马兴德","汪慧和","王艳","冯志霞","王志成","张云飞","王海珍","杨野","张燕","唐月晨","李瑞红","李婷华","赵栋","张季跃","孔维滢","穷吉","狄慧","达拉草","杨其菊","马凯军","陈亚茹","常惠琢","马昕璐", "王玉兰", "白玛次仁", "王瑜", "杨蓉庆", "刘志梅", "周强","李清华","李晓菁","徐思","邹丰蔚","罗松","杨玲","王燕","韩腊梅", "东文财", "焦旭超"};
//用于存储名字的标签
JLabel name = new JLabel(); //按钮
JButton btn = new JButton("开始点名"); //采用的是伪随机数,大家也可以不用这个,这个在网上可以找到java随机数的设置 R
Random rd = new Random();
public void init() { //提示标签页面
JLabel jt= new JLabel("随机点名器"); //设置标签居中
jt.setHorizontalAlignment(SwingConstants.CENTER); //设置字体大小
jt.setFont(new java.awt.Font("随机点名器",1,35)); //设置名字显示的标签居中
name.setHorizontalAlignment(SwingConstants.CENTER); //通过匿名类实现Action按钮的监听事件
btn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String n=getRandomName();
//设置name标签的文字
name.setText(n);
//设置字体
name.setFont(new java.awt.Font(n,1,35));
//设置字体颜色
name.setForeground(Color.blue);
}
});
//获取JFrame的面板
Container p = this.rFrame.getContentPane();
//设置布局方式,我采用的BorderLayout布局
p.setLayout(new BorderLayout(3,1));
//添加提示标签在北方
p.add(jt,BorderLayout.NORTH);
//添加姓名标签在中央
p.add(name,BorderLayout.CENTER); //添加按钮控件在南方
p.add(btn,BorderLayout.SOUTH); //调整大小,这个是java中无法设置标签的大小
rFrame.pack(); //设置窗体大小
rFrame.setSize(300, 300);
//设置可以显示
rFrame.setVisible(true);
}
//获取随机的姓名
public String getRandomName() {
int a = 0;
//random类去实现随机数时,只能设置上限,也就是说随机数产生的都是0-stuName.length之间的数字
a = rd.nextInt(stuName.length); //rd.setSeed();
//a = (int)Math.random()*stuName.length;
return stuName[a];
}
public static void main(String[] args) {
Fire rn=new Fire();
rn.init();
}
}

Fire

实验总结:

通过这次实验掌握了事件处理的基本原理、 AWT事件模型的工作机制; 掌握了事件处理的基本编程模型;了解了GUI界面组件观感设置方法;学习了WindowAdapter类、AbstractAction类的用法 以及GUI程序中鼠标事件处理技术。发现自己很多不足之处,还需更加努力。

原文地址:https://www.cnblogs.com/qq97/p/10016130.html

时间: 2024-08-28 04:47:45

201771010141 周强《面向对象程序设计(java)》第十三周学习总结的相关文章

201771010123汪慧和《面向对象程序设计Java》第二周学习总结

一.理论知识部分 1.标识符由字母.下划线.美元符号和数字组成, 且第一个符号不能为数字.标识符可用作: 类名.变量名.方法名.数组名.文件名等.第二部分:理论知识学习部分 2.关键字就是Java语言中已经被赋予特定意义 的一些单词. ?常见有:class.public.try.catch.if. float.import.void等. 关键字不做变量名. 3.Java有三种注释的方式:   // 注释内容由//一直到此行结束. /*和*/ 定义一个注释块.  /**开始,*/结束 这种注释方法

201777010217-金云馨《面向对象程序设计(Java)》第二周学习总结

项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p/11475377.html 作业学习目标 学习并掌握Java Application程序结构: 学习并掌握Java语言的数据类型与变量: 学会使用Java运算符构造各类表达式: 掌握Java Application输入输出技术: 掌握Java流程控制技术(分支.循环): 掌握Math类.Strin

201771010134杨其菊《面向对象程序设计java》第十周学习总结

第8章泛型程序设计学习总结 第一部分:理论知识 主要内容:   什么是泛型程序设计                   泛型类的声明及实例化的方法               泛型方法的定义                     泛型接口的定义                    泛型类型的继承规则                    通配符类型及使用方法 1:泛型类的定义 (1) 一个泛型类(generic class)就是具有一个或多个类型变量的类,即创建用类型作为参数的类.如一个泛型

20182332 2019-2020-1 《数据结构与面向对象程序设计》第1周学习总结

20182332 2019-2020-1 <数据结构与面向对象程序设计>第1周学习总结1 教材学习内容总结 1.配置linux 虚拟机.java环境. 2.理解面向对象程序设计,包括属性.方法.封装等概念. Java基本结构,环境变量配置,集成开发环境. JAVA文件编译过程: 1.源文件由编译器编译成字节码(ByteCode) 2.字节码由java虚拟机解释运行. git命令: git init 创建本地版本库: git clone 与远程仓库建立联系: git add .将当前目录下文件添

《数据结构与面向对象程序设计》第5周学习总结

学号20182329 2019-2020-1 <数据结构与面向对象程序设计>第5周学习总结 教材学习内容总结 首先学习Java Socket的编程,后面实验45都要用到,来传递数据. 学习凯撒密码的使用方法 学习Java密码的DES算法和RSA算法还有HD算法 编写简单计算器(有理数计算器). 使用试验1里面的方法和实验三代码,编写客户端,客户端通过键盘输入一个有理数计算的公式(例如:1/4 + 1/6 = ),并把该公式以字符串的形式发送给伙伴B(服务器端),服务器端根据字符串计算出结果为5

20182332 2019-2020-1 《数据结构与面向对象程序设计》第八周学习总结

20182332 2019-2020-1 <数据结构与面向对象程序设计>第八周学习总结 教材学习内容总结 查找: 顺序查找: 顺序查找就是按顺序从头到尾依次往下查找,找到数据,则提前结束查找,找不到便一直查找下去,直到数据最后一位.适用于线性表的顺序存储结构和链式存储结构. 缺点:查找效率低. 二分查找: 将数列按有序化(递增或递减)排列,查找过程中采用跳跃式方式查找,即先以有序数列的中点位置为比较对象,如果要找的元素值小于该中点元素,则将待查序列缩小为左半部分,否则为右半部分.通过一次比较,

《数据结构与面向对象程序设计》第1周学习总结

学号 2019-2020-2314 <数据结构与面向对象程序设计>第1周学习总结 教材学习内容总结 1.计算机系统是由软硬件组成的 2.java程序的结构组成(注释.标识符和保留字等) 注:java是大小写敏感的,大写和小写是有区别的 3.程序开发所包含的内容(程序设计语言的等级.编辑器.编译程序.解释程序.开发环境和语法语义) 4.在开发软件的过程中遇到问题时的解决步骤:理解问题.设计方案.考虑方案的选择并优化方案.实现方案.测试方案并修改存在的任何问题. 教材学习中的问题和解决过程 问题1

20182329 2019-2020-1 《数据结构与面向对象程序设计》第1周学习总结

20182329 2019-2020-1 <数据结构与面向对象程序设计>第1周学习总结 教材学习内容总结 git代码托管代码 Java的基本编程 jdb代码调试 教材学习中的问题和解决过程 问题1:在课本自学过程中,有一题是Java中有什么是不可能被识别的,我做错了一道(12345)可以被识别. 问题1解决方案:后来询问学长数字不与命令相匹配时不是有效的标识符,且标识符不能以数字为开头. 问题2:在自己对于课本代码编译时,发现自己main处显示错误 问题2解决方案:一开始我以为是我main的方

《数据结构与面向对象程序设计》第01周学习总结

目录 学号20182323 2019-2020-1 <数据结构与面向对象程序设计>第01周学习总结 教材学习内容总结 教材学习中的问题和解决过程 代码调试中的问题和解决过程 代码托管 上周考试错题总结 结对及互评 点评模板: 点评过的同学博客和代码 其他(感悟.思考等,可选) 学习进度条 参考资料 目录 学号20182323 2019-2020-1 <数据结构与面向对象程序设计>第01周学习总结 教材学习内容总结 学习了java的历史与发展. 学习了一些软件工具,开发环境等. 掌握

《数据结构与面向对象程序设计》第2-3周学习总结

学号20182329 2019-2020-1 <数据结构与面向对象程序设计>第2-3周学习总结 教材学习内容总结 条件语句和循环语句的使用 输入语句和输出语局应用 基本数据类型的转换和应用 各种类的使用方法,以及格式化输出的方法. 基本的类的编写 教材学习中的问题和解决过程 问题1:scanner输入时用short nextShort()输入时出现异常. 问题1解决方案:输入时应与前一项自己指定的数据类型一样才可以. 问题2:在应用impoet时使用import Java.util.*时并不会