Java/JSP/Overloading Methods — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 10:09, 1 июня 2010
Содержание
Overloading Methods
<source lang="java">
<HTML>
<HEAD> <TITLE>Overloading Methods</TITLE> </HEAD> <BODY>
Overloading Methods
<%! javax.servlet.jsp.JspWriter localOut; void printText() throws java.io.IOException { localOut.println("Hello!
"); } void printText(String s) throws java.io.IOException { localOut.println(s + "
"); } %> <% localOut = out; printText(); printText("Hello from JSP!"); %> </BODY>
</HTML>
</source>
Overriding Methods 2
<source lang="java">
<HTML>
<HEAD> <TITLE>Overriding Methods</TITLE> </HEAD> <BODY>
Overriding Methods
<%! javax.servlet.jsp.JspWriter localOut; class animal { public void breathe() throws java.io.IOException { localOut.println("Breathing...
"); } } class trout extends animal { public void breathe() throws java.io.IOException { localOut.println("Gilling...
"); } } %> <% localOut = out; out.println("Creating an animal object...
"); animal a = new animal(); a.breathe(); out.println(); out.println("Creating a trout object...
"); trout t = new trout(); t.breathe(); %> </BODY>
</HTML>
</source>