Search:

Type: Posts; User: SamJava_the_Hut

Page 1 of 3 1 2 3

Search: Search took 0.09 seconds.

  1. Problem with option scanner input for a switch statement

    I'm just trying to create a simple switch statement structure:

    SwitchStatement.java:


    public class SwitchStatement {

    public void displayMenu() {
    System.out.println("Select a...
  2. Re: I wanted to output the string itself, but the output looks like it's been encrypted or something

    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...
  3. Re: I wanted to output the string itself, but the output looks like it's been encrypted or something

    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...
  4. Re: I wanted to output the string itself, but the output looks like it's been encrypted or something

    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...
  5. My copied array is empty, and I don't know why.

    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

    ...
  6. Trouble when I try to do without using a compound assignment operator

    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...
  7. How to print out class parameters properly

    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.*;
  8. Re: Multiple scope problems with interfaces

    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...
  9. Re: Multiple scope problems with interfaces

    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...
  10. Re: Multiple scope problems with interfaces

    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...
  11. Re: Multiple scope problems with interfaces

    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...
  12. Multiple scope problems with interfaces

    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 {
  13. Re: Understanding the mechanics of swapping variables for the quicksort algorithm

    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...
  14. Re: Understanding the mechanics of swapping variables for the quicksort algorithm

    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...
  15. Understanding the mechanics of swapping variables for the quicksort algorithm

    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...
  16. ClickListener cannot be resolved to a type

    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...
  17. Re: My second adventure of working with inheritance

    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...
  18. My second adventure of working with inheritance

    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,...
  19. Re: Better ways to round floats and/or doubles?

    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:...
  20. Better ways to round floats and/or doubles?

    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:

    ...
  21. Re: I wanted to output the string itself, but the output looks like it's been encrypted or something

    It works! Thanks Norm:


    public static String fixBadStr(char[] badStrToChars, char[] goodStrToChars) {
    for(int i = 0; i < badStrToChars.length; i++) {
    if(badStrToChars[i] !=...
  22. I wanted to output the string itself, but the output looks like it's been encrypted or something

    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...
  23. Re: My first adventure for working with inheritance

    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...
  24. Re: My first adventure for working with inheritance

    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...
  25. Re: My first adventure for working with inheritance

    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...
Results 1 to 25 of 54
Page 1 of 3 1 2 3