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