57 lines
2.7 KiB
HTML
57 lines
2.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>NoWildCard.java</title>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<style type="text/css">
|
|
<!--
|
|
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
|
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
|
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
|
|
.literal {color: #cc7832}
|
|
.number {color: #6897bb}
|
|
.string {color: #6a8759}
|
|
.comment {color: #808080}
|
|
.whitespace {color: #505050}
|
|
-->
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/NoWildCard.java</td></tr></table>
|
|
<pre>
|
|
<span class="comment">/*</span>
|
|
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
|
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
|
<span class="comment"> */</span>
|
|
<span class="literal">package</span> edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
|
|
|
|
<span class="comment">/**</span>
|
|
<span class="comment"> *</span>
|
|
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
|
|
<span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">class</span> NoWildCard {
|
|
|
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">double</span> max(GenericStack<Integer> stack) {
|
|
<span class="literal">double</span> max = Double.MIN_VALUE;
|
|
|
|
<span class="literal">while</span> (!stack.isEmpty()) {
|
|
<span class="literal">double</span> value = stack.pop().doubleValue();
|
|
<span class="literal">if</span> (value > max) {
|
|
max = value;
|
|
}
|
|
}
|
|
<span class="literal">return</span> max;
|
|
}
|
|
|
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args) {
|
|
GenericStack<Integer> intStack = <span class="literal">new</span> GenericStack<>();
|
|
intStack.push(<span class="number">1</span>);
|
|
intStack.push(<span class="number">2</span>);
|
|
intStack.push(-<span class="number">2</span>);
|
|
System.out.print(<span class="string">"</span><span class="string">The max number is </span><span class="string">"</span> + max(intStack));
|
|
}
|
|
}
|
|
|
|
</pre></body>
|
|
</html>
|