56 lines
2.4 KiB
HTML
56 lines
2.4 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>ArrayShift2.java</title>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<style type="text/css">
|
|
<!--
|
|
body {color: #000000; background-color: #ffffff; font-family: monospace}
|
|
pre {color: #000000; background-color: #ffffff; font-family: monospace}
|
|
table {color: #404040; background-color: #e9e8e2; font-family: monospace}
|
|
.ST0 {color: #969696; font-family: monospace; font-weight: bold}
|
|
.comment {color: #969696}
|
|
.string {color: #1e9347}
|
|
.literal {color: #336bdd}
|
|
-->
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Assignments/lab16_arrays2_CalebFontenot/src/main/java/com/calebfontenot/lab16_arrays2_calebfontenot/ArrayShift2.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> com.calebfontenot.lab16_arrays2_calebfontenot;
|
|
|
|
<span class="comment">/**</span>
|
|
<span class="comment"> *</span>
|
|
<span class="comment"> * </span><span class="ST0">@author</span> <span class="comment">caleb</span>
|
|
<span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">class</span> ArrayShift2 {
|
|
|
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
|
{
|
|
<span class="literal">int</span>[] ar = {1, 2, 3, 4, 5};
|
|
<span class="literal">int</span> temp = ar[ar.length - 1];
|
|
|
|
<span class="literal">for</span> (<span class="literal">int</span> value : ar) {
|
|
System.out.print(value + <span class="string">"</span> <span class="string">"</span>);
|
|
}
|
|
System.out.println();
|
|
|
|
<span class="literal">for</span> (<span class="literal">int</span> i = (ar.length -1); i > 0 ; --i) {
|
|
ar[i] = ar[i -1];
|
|
}
|
|
ar[0] = temp;
|
|
|
|
<span class="literal">for</span> (<span class="literal">int</span> value : ar) {
|
|
System.out.print(value + <span class="string">"</span> <span class="string">"</span>);
|
|
}
|
|
}
|
|
}
|
|
|
|
</pre></body>
|
|
</html>
|