I'm just trying to create a simple switch statement structure:
SwitchStatement.java:
public class SwitchStatement {
public void displayMenu() {
System.out.println("Select a...
Type: Posts; User: SamJava_the_Hut
I'm just trying to create a simple switch statement structure:
SwitchStatement.java:
public class SwitchStatement {
public void displayMenu() {
System.out.println("Select a...
The overall goal of this entire program is to overwrite the old badStr with the goodStr, regardless of what length the strings are. The overwritten badStr is the fixed version that of the badStr, and...
Norm, I am getting way closer! The IndexOutOfBoundsException problem is gone. Below is my updated code:
FixString.java
package samsExperiments;
import java.util.Scanner;
import...
I'm now trying to fix my bad string with array lists instead of regular arrays. If I use regular arrays, the program crashes with an array out of bounds error if the badStr and goodStr strings are...
Doing some array experimenting, I attempted to to copy each element matching the value a user is looking for from the "arr" array to the "valuesFound" array Here's my code:
SamsArrays.java
...
I'm encountering some unexpected error messages when I try to do without a compound assignment operator. Here's my code:
package samsExperiments;
public class SamsArrays {
public int...
I'm trying to get a cloneable interface to work. Here's what I have so far:
Driver.java
package interfaces.business;
import java.util.Scanner;
import java.time.*;
Norm, that's not the point. Giving a method a body defines the method (or in this case, would redefine a default method). What would be the point of defining a default method in an interface ahead of...
Thank you Norm. On to the next thing. Even with the tutorial link you gave me, I'm still having trouble with calling default methods. Here's my updated code:
Printable.java
package...
You're dead right. So why are default methods (non-static interface methods with a body) useful then? How do you implement them? Even if you can pass them around interfaces, what good does that do if...
Lets forget about that. I was misusing it anyway 8-}
If you look at my Main class (of which the red around the Main keyword of the class signature is now gone, because I implemented the methods...
I'm trying to learn how use interfaces. My package hierarchy looks like this:
3583
SelfDrivable.java
package interfaces.business;
import java.util.Scanner;
public interface SelfDrivable {
x and y were never variables in the actual code. If you read the first statement of my green text in that post:
In order for the element on the the left portion of the partition (x) to swap with...
Okay, lets start over, following this guy's example:
https://www.youtube.com/watch?v=Fiot5yuwPAg&t=315s
According to him, the quick sort algorithm is explained like this:
In order for the...
I'm trying to learn the swap functionality for the quick sort algorithm, but the variable swapping seems to be going around in circles.
Here is the class with the partition and quickSort...
Hi. I'm just starting to learn about inner classes. The following code is an example I followed from my book, but I still don't fully understand the explanation on lines 22 - 24:
package...
New problem.
The same kind of error, "The method setBladeType(String) is undefined for the type Construction" on lines 12 - 32 occurs in my database class, but only for the Construction child...
Hi, I'm working on another inheritance project, this time with blade objects.
Line 9 of the following child class:
package blade.business;
//This is a child class of the Blade class,...
Thanks Jim, it works;)
//how to control the how many numbers are to the right of a decimal point:
double roundMe = 176.71458676442586;
System.out.printf("Our shortened double is now:...
Hi. I'm trying to figure out how to round floating point numbers with more flexibility than just rounding to integers or rounding to two decimal places.
Here is the class with my methods:
...
It works! Thanks Norm:
public static String fixBadStr(char[] badStrToChars, char[] goodStrToChars) {
for(int i = 0; i < badStrToChars.length; i++) {
if(badStrToChars[i] !=...
Hi, I'm trying to fix a string from "hollo werld" to "hello world". To do this, I made another string of what we want, turned both of them into char arrays, and iterated through, changing elements as...
The code finally does what I want! There's just one little problem. The program says, "Bye!" and quits before the user can input a y or n to choose to continue or not to continue:
package...
Well, I chose the latter, but I'm still getting the same error several times in the code (for example on line 12, "The method setSerialNumber() in the type Vehicle is not applicable for the arguments...
Ok, I finally did what you said, the warnings such as "The assignment to variable seatCount has no effect" in the SUV, Truck, and Sedan setter class methods have gone away.
Unfortunately, the...