From 174fbc4ea92c65748aa0258d9d2d0c590588f855 Mon Sep 17 00:00:00 2001 From: huyingying <1811054376@qq.com> Date: Sun, 2 Jun 2024 14:25:52 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- work/web/WEB-INF/classes/Homework.jsp | 65 +++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 work/web/WEB-INF/classes/Homework.jsp diff --git a/work/web/WEB-INF/classes/Homework.jsp b/work/web/WEB-INF/classes/Homework.jsp new file mode 100644 index 0000000..490072b --- /dev/null +++ b/work/web/WEB-INF/classes/Homework.jsp @@ -0,0 +1,65 @@ +<%-- + Created by IntelliJ IDEA. + User: Administrator + Date: 2024-06-02 + Time: 13:34 + To change this template use File | Settings | File Templates. +--%> +<%@ page contentType="text/html;charset=UTF-8" language="java" %> + + + Homework + + +<%--.定义一个Animal类,并在类中定义一个String sleep(int time)的成员方法;--%> +<%! + class Animal{ + String sleep(int time){ + return "一只动物在睡觉"; + } + } + %> +<%! + //定义一个Cat类,包含name及time的属性,并定义String sleep(int time)的方法; + class Cat{ + String name; + int time; + String sleep(int time){ + return "一只"+name+"睡觉睡了"+time+"个小时"; + } + } +%> +<% + Animal animal = new Animal(); + out.println(animal.sleep(3)); + %> +
+<% + Cat cat = new Cat(); + cat.name="汤姆猫"; + out.println(cat.sleep(8)); +%> +<%--在jsp页面中展示九九乘法口诀--%> + +<% + for (int i = 1; i <=9 ; i++) { +%> + +<% + for (int j = 1; j <=i ; j++) { +%> + + <% + } + %> + + <% + } + %> +
+ <% + out.print(i+"*"+j+"="+(i*j)); + %> +
+ + -- Gitee