BestJewSinceJC 700 Posting Maven

What is UserInput.prompt?

Use Scanner to get input from the user, unless you were directed otherwise by your instructor. For example,

Scanner userInput = new Scanner(System.in);

//System.in is connected to the keyboard by default, so the statement above will create a Scanner object called userInput that allows you to read in input. Google "Java Scanner" to see the methods it supports.

Also, friendly tip: post as many details as necessary, but don't post more. Try to identify the problem & if you can't fix it, post it on here. If you can't identify the problem, fine, just post your code and post the errors you are getting.

BestJewSinceJC 700 Posting Maven

Its because hasNextLine() will return true if there is a next line, even if that line does NOT contain any information. In other words, if there is a newline character, hasNextLine() will return true. Whereas hasNext() will only return true if there is a next token. A token is defined as anything that is preceded and followed by the delimiter pattern, (which is whitespace by default). In other words, change it to hasNext() and it will work. Also, read this...


http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html#hasNext()

BestJewSinceJC 700 Posting Maven

I'd be willing to bet that if you changed your code to this, then your code would work. I've never actually seen somebody use "File" as an argument to a Scanner, so excuse me if I'm wrong, but I don't think it should be used. File is a class that represents a File, is it not? A File and a FileInputStream are not the same thing, I don't think. Try this..

Scanner whatever = new Scanner(new FileInputStream(yourFileHere));

BestJewSinceJC 700 Posting Maven

One good way to do this would be the following

//assuming your Scanner object is called input
do{
   int choice = -1;
   System.out.println(//Print out your choices here);
      if(input.hasNextInt()){
        choice = input.nextInt();
        //call some method that does the calculations here. 
       // the method will take 'choice' as its argument
       //so that it knows what to do. (i.e if choice is 1, 
       //then do Celsius or whatever you wanted.
} else{
   System.out.println("Incorrect choice entered, choice ignored. Enter valid input.");
}

}while(choice != 3)
BestJewSinceJC 700 Posting Maven

Write a while loop that loops indefinitely while the user does not enter a specific value. Inside that while loop, you should simply print out something like "Enter your calculation or enter X to quit the program." Then, it should read in the user's input using scanf (might be other alternatives, I don't remember). If the input doesn't indicate that the user wants to quit, you then have two options as far as your programs design goes:

You can allow the user to input a full sequence that he/she wants your program to do the arithmetic for. For example, 5 x 4. This will be much harder because you will have to call a function to parse the input, then do the arithmetic. Or, you can display menu choices according to the rules for inputting the stuff to calculate. For example, you could say "Enter 1 if you want to multiply stuff". Then, if the user types 1, you could output: Enter the first number to be multiplied. (And after they do that)... Now enter the second number to multiply it with. Etc.

Hopefully that is helpful.

BestJewSinceJC 700 Posting Maven

No it wouldn't. And why are you arguing with me anyway? I already explained that I haven't programmed in C in quite a while. If you disagree with something I said, then it is on you to prove me wrong. There isn't much for me to prove since the code works. Btw, scanf returns the number of arguments successfully read. It can also return EOF but I hardly think that is a problem here, although it might be a good idea to add || EOF to that if statement.


To test to verify that the result would be 0 on bad input, go run the program and type in anything that isn't an integer.

BestJewSinceJC 700 Posting Maven

Lol, k

PS: @OP, like I said, I haven't coded in C in awhile, but I believe what the nerd above me was talking about is the following:

int result = scanf("%d", &currentValue);
      if (result == 0){
         return 0;
      }

Hardly exciting, I guess I learned quickly. Although no input checking was necessary since you stated in your problem that inputs were guaranteed to be integers.

BestJewSinceJC 700 Posting Maven

This is what files are for. Just store the data from the non-Java application into a file, and then read that data from your Java application.

I'm pretty sure its more complicated than that. If you read his original statement, it sounds like he wants both programs to be running at once. In which case, I'm sure there are issues with concurrent modification, and there might be issues if he actually wants to read the integer from the memory location (which I guess would require having one program tell the other where the int is stored for starters). Also, one program might have to be embedded in another to accomplish this, although I don't know anything about that. Just throwing some things out there, not as statements of assurance, just as guesses. It'll be interesting to see what someone with more experience has to say about this.

BestJewSinceJC 700 Posting Maven
#include <stdlib.h>
#include <stdio.h>

int main(){
int nrEvens = 0;
int nrOdds = 0;
int nrInputs = 0;
int currentValue;

while(nrInputs < 20){
printf("Enter a number: ");
scanf("%d", &currentValue);
if (currentValue % 2 == 0){
nrEvens++
} else{
nrOdds++;
}
nrInputs++;
}

printf("There were %d even values entered and %d odd values entered.", nrEvens, nrOdds);

return 0;
}

This is the correct code. I will add comments shortly to explain how this works. You should seriously consider learning how to do it on your own, otherwise, you will not pass your class.

BestJewSinceJC 700 Posting Maven

Yes. I'm not sure how though. :)

You can embed languages, and you can also always store the result then access it later. I'm sure someone else will explain much better.

BestJewSinceJC 700 Posting Maven

this is the file bellow .. download and explain what u understand my frind

This (your existence on this site) must be some kind of a sociology experiment. If so, I guess the goal would be to figure out how much help you can receive from people while disregarding what they say, being annoying, and ignoring all of the rules for human social interaction.


Ask a specific question: this involves identifying some specific concept you do not fully understand and explaining what you do and don't understand about it, as well as your reasons (if any) for not understanding.

dickersonka commented: couldn't have put it better myself +2
BestJewSinceJC 700 Posting Maven

If you are using the LinkedList class, use yourObjectName.remove(index); . It will do all the necessary operations for you, such as making the previous and next nodes point to each other. Since I see that you're not using that class, I would strongly recommend that you do so. Otherwise, you're wasting your time. However, if you insist on doing it your way,

code to remove your node:

public Node removeNode(int index){
//the reason its silly for you not to keep some sort of a list is because when you want to remove a Node (the way you're doing it), you have to traverse the list until you get to the 'previous node', store that, then traverse until you get to the 'next node', store that, then set the previous node to point to the next node. Then, you're done, since Java does the garbage collection for you (you don't need to free anything).
//If that last sentence doesn't make sense, forget about it for now. 

http://www.faqs.org/docs/javap/c11/s2.html

-Edit-

Actually, see the delete() method at the end of that FAQ.


}
BestJewSinceJC 700 Posting Maven

Ok, I see. So in my case, if I give each of the JLabels (added in column 1) weightx = 1, they will get that extra space. Also, the layout is working fine right now, so I don't think I will need the anchor. I will resize the window a few times and see what happens and take that into consideration though. Thanks a lot for your help. I'll mark this as solved if I don't have any more questions.


Edit:

setting weightx and weighty aren't having any effect at all on the extra space. The component at the very top is twice as long as the text fields are. Does that have any effect on what is considered extra space?

BestJewSinceJC 700 Posting Maven

I figured it out (literally, like two minutes ago, so sorry for not posting about it) - I was using RELATIVE when I should have been explicitly setting gridx and gridy to whatever they needed to be. I'm not saying it would've been impossible to use RELATIVE, but it was easier the other way.

Also, I have extra space between each JLabel and JTextField. So, like I said above it looks like

JLabel toomuchspace JText

you're saying setting weightx to 0 will get rid of some of the extra space? I already read about weightx and weighty (I read the whole tutorial on GridBayLayout), but thats not what I understood from it. But I will try that. Thanks.

BestJewSinceJC 700 Posting Maven
//Fig.2.7:Inventory.java
//Inventory program

public class Inventory
{
	//main method begins execution of Java application
public static void main(String[] args) {
	
 //You need to create a Scanner object. Below, we create a Scanner object called 'input'.
 //We use System.in because we want to read input from the keyboard.
		Scanner input = new Scanner(System.in);

       //To declare the variables below, we do NOT need a new class. 
       //We can just declare them in this method.
       //Each declaration should only have one type, as I edited below.
	String productName;
	int productNumber;
	int productStockAmount;
	int productPrice;
	int stockValue;

        while(true){
	System.out.print( “Enter product name: ” ); //prompt
	productName = input.nextLine(); // gets the line of input the user typed

        //Note: this code is wrong: the format ###-##-### is NOT an integer
        //therefore, you can't save it into an integer variable! number1 is an 
        // integer variable, and this code will not work. You can, however,
        //declare number1 as a 'String' and it will work. 
	System.out.print( “Product number: ###-##-###: “ ); //prompt
	number1 = input.nextLine(); 

	System.out.print( “Product stock amount: “ ); //prompt
	number2 = input.nextLine(); 

        //Again, this will not work because ##.## is not an integer. 
        //It is a decimal number, so use float or double. 
        // Go back to where number3 is declared in your code and change it from int
        // to either float or double.
	System.out.print( “Product price: $##.##: “ ); //prompt
	number3 = input.nextLine(); 

       //Amount has to be a float or a double for the same reason listed above.
	amount = number2 …
BestJewSinceJC 700 Posting Maven

If you want to create a jar very easily, one way you can do it is by using the Eclipse IDE. To create a jar in eclipse,

file-> export -> Jar File (this might be listed under 'java' -> next, and under manifest class you would select the main class that you want to run when the program is started,.

BestJewSinceJC 700 Posting Maven

Eh, no thanks. I want to learn how to do it myself. But I also can't do that because my project is already finished, practically. I don't know how to use netbeans to begin with, so integrating it with an already started project would be foolish at this point. But I do appreciate the advice, I plan to use netbeans once I become more experienced without it.

BestJewSinceJC 700 Posting Maven

Alternatively, are there any layout managers that will make it easy to lay out what I described above, but that will NOT put huge amounts of space inbetween the labels & the textfields? GridLayout puts way too much space between the labels and panels, which is the reason I switched to begin with; the way GridLayout aligns it forces the tab of the JTabbedPane to be larger than it should be (the area that I see on screen is larger than I want it to be).

BestJewSinceJC 700 Posting Maven

I'm confused how GridBagLayout can be used as if it was GridLayout(0,2).

For example, I would like to lay out components like this:

Label TextFieldForLabel
Label TextFieldForLabel
Label TextFieldForLabel
Label TextFieldForLabel

I thought by making a GridBagConstraints() Object, then setting the gridx and gridy variables, this could be accomplished (Java Sun tutorials). However, I have tried numerous ways of doing this, and I can't get anything laid out correctly. In my code, I tried the following:

-using a pattern of setting gridx to "RELATIVE" and setting gridy to 0, then I'd set gridy to RELATIVE and gridx to 0 for the next component I added.

I also tried a few other ways that didn't work.

BestJewSinceJC 700 Posting Maven

Are you dense? Stultuske just posted a number of different things to help you. If you don't understand a particular one, try to research it online or ask him to elaborate here. If you don't know any Java at all, which it seems like you do not, find a good tutorial online and read it. If you don't understand things in the tutorial, you can ask questions about it here. You're only going to annoy people if you don't have enough experience to know what an Object is, for example. READ

BestJewSinceJC 700 Posting Maven

The String method compareToIgnoreCase should do the trick. For example:

int result = string1.compareToIgnoreCase(string2);
// here result < 0 if string1 > string2
// or result = 0 if string1 == string2
// or result > 0 if string1 < string2

That should give you a start anyway. Have a go and see what you can come up with.

Are you sure about that? I thought it just added the value of the separate characters for each String, then compared those values. Which would not put them in alphabetical order. I'm not saying you're wrong, just curious.

BestJewSinceJC 700 Posting Maven

Considering that there is a class available that will do this for you, LinkedList, I'm assuming this is some sort of assignment? (Which is fine)


Anyway... pseudocode to do this


-Given the index you want to remove
-set the node at the previous index to point to the node at the next index
-set the index you want to remove as pointing to nothing, this includes setting its previous and next nodes to null if you are in a doubly linked list. If its a singly linked list, then you only have to set next to null
-Java does garbage collection for you, so you're done.

BestJewSinceJC 700 Posting Maven

If this means anything to anyone here I think it will be a small miracle.

BestJewSinceJC 700 Posting Maven

the BankAccount constructor should call a deposit method to allow the user to add some money if he or she wants to. However, the parameter which passes the value to the deposit method is not available for this constructor and I know that I can not simply add that parameter to the BankAccount constructor. Right now, I have decided to use a separate variable for that constructor exclusively, but I am afraid it my break my partner's code. What would be a better way to go about this?

That doesn't make a whole lot of sense to me. If you want a bank account to have an initial balance (that isn't 0), and that is based on a previous account, pass that amount into the constructor as a parameter. Then set the 'amount' variable to the amount passed in. You don't need to use the deposit method at all in your constructor. Also, there should be no reason your partner can break your code. . all that anyone using your code should need to know are the parameters necessary to call the method, what those parameters represent, and what the outcome of the method call should be. They don't need to know any of the details.

If that isn't helpful you will need to elaborate on what your problem is.

BestJewSinceJC 700 Posting Maven

You want to put your choices in a while loop, so that they will continuously be displayed on the screen.

while(true){

// Your choices that you listed above go here. The way the program should exit is when the user inputs '4' to exit, you should say System.exit(0);
// You also need [I]methods[/I] that get called when the user makes certain choices. For example, the code below this line:

if (choice == 2){
//there was a withdrawal
withdrawal(personsBalance); // see below
}

}


public String withdrawal(int balance){
//Need code here, similar to Scanner code in main, that asks the user how much they want to withdraw. lets call it amount. Alternatively, you could ask the user back in main what amount they want to withdraw, then pass it as an argument to this method.
if (amount <= balance){
balance = balance - amount; // this will NOT really update your balance. to do that you'd have to create an Object, call the withdrawal method with it, and then say yourObject.balance = yourObject.balance - amount. OR you could use static variables (but I don't recommend that for this problem)
return "success";}else{
return "failure";
}


}

The above code is similar to what you want. I didn't check all cases because I'm in a rush right now, just popped into this thread. So don't get hung up on one little detail if you don't see it there, its just a general outline. Basically, you should be using method calls to handle …

BestJewSinceJC 700 Posting Maven

To restate my earlier post, what I said only applies if the variable is static. Otherwise, you need to create a new object in order to refer to 'q' -- which is what javaAddict did. (In other words what javaAddict did is what you have to do if its a public, non-static variable. What I did in my first post is what you'd do for a static variable.)

BestJewSinceJC 700 Posting Maven

You would keep a pointer to the String that you wish to store it in and concatenate your 'new' user entry onto whatever the String's current contents are. OR you could make the function 'return' whatever the user entered as a String, and concatenate that entry with whats stored in the current String.


I haven't coded in C recently, but those are the only two ways you can do this. The pseudocode for the second way would look like this:

int main(){
String allTextEntered;
String currentEntry = interactive();
allTextEntered + currentEntry; //PSEUDOCODE - WONT WORK AS TYPED. CONCEPT WORKS.
}

String interactive(){
//code to get text from the user

return userEntry;
}

BestJewSinceJC 700 Posting Maven

If it is public, then you can use

Classname.variableName to refer to it. In this case, that means saying C.q
This only applies if they are in the same package, which in your case, they are. If they were in a different package, you could say packageName.Classname.Variablename

BestJewSinceJC 700 Posting Maven

If you're only allowed to use the methods defined in the MyArrayList class, then that depends entirely on what methods are in that class. I'm assuming it has a push() and pop() method, so you can "fake" the peek method by pop()ing something off, saving it into a variable, and immediately push()ing it back onto the stack.

BestJewSinceJC 700 Posting Maven

Correct me if I'm wrong, but it seems like you just posted an entire assignment, but didn't give any insight on how you've been trying to solve the problem - or even what the problem is. So we can only assume that you didn't actually attempt the assignment. I'd recommend coming back when you have ideas/attempts/something to share that shows you tried. Then I'd be glad to help you.

BestJewSinceJC 700 Posting Maven

Yeah, I figured as much after your (Ezzaral) and Stul made your posts. I got the GUI working already in light of what you guys told me. Thanks for the articles though, I'll def. check those out. And thanks for all the help.

jasimp commented: Wow. An actual thank you. +9
BestJewSinceJC 700 Posting Maven

Ahh. I see. Thank you, I will do that. It'll be a bit harder considering I have 5 or 6 GUIs but I get the idea, I think.

BestJewSinceJC 700 Posting Maven

Yeah, no problem.

The revalidate description says it is unnecessary in most cases, though. And trying to use it has caused my program to become non-responsive, although this could be my fault. This sucks - I've been working to try to figure out how this stuff works all day and I've literally made backwards progress - my program works worse than it did when I started.


Edit:


I give up unless somebody wants to help out some more or go into more detail about what needs to be done. It isn't for lack of effort, since as anyone can see, I've been at this all day. And I've read almost all of the Sun tutorials on this subject so I don't understand why I can't figure out whats wrong.

BestJewSinceJC 700 Posting Maven

Excellent man. Thanks for the help. I'm adding you reputation pts for what thats worth.

Also, your explanation would require that my JPanel in the first class is static, would it not? Because if it isn't static, then my other GUI class has no way of revalidating the JPanel from the first class.

BestJewSinceJC 700 Posting Maven

Perhaps I am missing the point. If so, I apologize, but here's some more info so can you can put what you said in context for me please?

I have two GUIs that I was to interact with each other. What happens in one GUI is dependent on what happens in the other GUI. For example, in the one GUI, I have a list of Teams being displayed in a JTable. In the other GUI, I have a list of Games that one of the Teams (from the previous GUI) has played. When I delete one of these games, I want the first GUI to respond by updating the entire GUI so that it will reflect the changes.

So you're saying all I have to do to accomplish this task is by saying JPanelFromFirstGUI.revalidate()? Where would the revalidate code go? In the second GUI? I apologize, but I can't find any information about this in the java Sun tutorials or anywhere else... all I can find are easy examples that I know how to implement.

thanks

BestJewSinceJC 700 Posting Maven

So if I have a static JFrame which has a JPanel which has a static JTable inside of it, should I do JTable.removeAll() ? And if so, how should I re-add all of the data to it? Simply say (if table is my JTable) table = new JTable(data, columns)?


Actually, judging by what you said, I'm thinking I should use JFrame.removeAll(), since things are being added to the JFrame each time... and there will still be components in it if I only use Jtable.removeAll()

thanks man


Also, if I just do what I said above, and removeAll() of the components, then add them back in their updated form, do I still need to revalidate() ?

BestJewSinceJC 700 Posting Maven

Man, I'm so confused still. I can't even figure out a way to have multiple GUIs interact when each class extends JPanel & has a static JFrame variable. I've been trying a variety of different things but nothing really works. If anyone has any source code of multi-GUI projects that you have built or someone else has built, where each GUI is able to 'update' itself based on changes made to Objects (could be in a list or otherwise) through another GUI, please provide it.

I don't have any trouble building a stand-alone GUI like the ones in the Java Sun tutorials. Ugh.

BestJewSinceJC 700 Posting Maven

Only when a new instance is created. Or, rather, when the current instance is 'un-hidden'. But it doesn't really matter since all of my GUIs will simply supply an error message if the user enters something inconsistent with whats in the ArrayList that they all use. So I'm pretty sure that the worst that can happen is that there is incorrect information being displayed on screen. Of course, I am going to try to prevent that. But at this point, my main concern is making sure the data that is IN the ArrayList remains intact.

BestJewSinceJC 700 Posting Maven

Data is initially gotten out of a file by the first GUI. When the program is closed, it is written back into the file by the same GUI. The user can enter data that manipulates the data originally gotten out of the file. In addition, the user can enter data that will be added to the file when the program closes. So yes, it is necessary to check for 'new' data every time some of my GUIs are opened, since the user could've entered new data or changed the data we currently have. So I don't see why I can't do what I described above and update the data every time the user opens a GUI. I'm sorry if I'm being confusing.

BestJewSinceJC 700 Posting Maven

I realize that... thats why I'm saying that when the user opens the GUI, I will update the information first. I haven't quite figured out how I'm going to update the information, but I'm sure there are adequate means to do so. Ezzaral gave me one way to do it with a JTable - I guess there are also ways to do it with JComboBoxes etc


If this isn't how I should be doing it, then how should I be updating the changes?

BestJewSinceJC 700 Posting Maven

The Java API says that the pack() method causes something that is dispose()'d to reappear.

Instead, I'm just going to hide the window when the user clicks out of it, then set it to visible when they click back into it. Each GUI class will have a method that gets called each time the user wants to view that GUI. This method will update the contents of the GUI before displaying it. While this might take more time to do (updating everything, every time) than simply updating something when the user makes changes... it doesn't matter to me because this application takes very little time to run anyway.

I'm just asking if this way of doing things will lead to funny results.

Also, one last question for now: Any code that interacts with the GUIs or is part of the GUIs apparently needs to be run on the event dispatch thread or a worker thread. How do I know if my code is running on the EDT other than using a method to determine it (I know there's a method that will tell me this)? Are any methods invoked from actionPerformed or other event handling methods guaranteed to be run on the EDT?

BestJewSinceJC 700 Posting Maven

So if my application has numerous GUIs, but only one is shown when the program starts, how does that figure into what you just said?

(which of the following things should I be doing)?

1. When the application is first launched, I set up all GUIs that can possibly be used at any point in the program, but I set them all to setVisible(false) except the one that I want to show up initially.
2. When the application is first launched, I only set up the first GUI. Then, if I open a different GUI, it is set up using that GUI's main method. But after it is set up initially, it will never be set up again & will only be hidden then redisplayed (possibly with information changed).


To me, the second one makes more sense, since I don't see any point in having all of the GUIs set up if the user isn't going to use them. However, if you recommend the other way, that is what I will do. The second way I described might be implemented something like this (where frame is a static variable):

public static void main(String[] args){

if (frame != null){
// code to update whatever is in the GUI
frame.setVisible();
} else if(frame == null){
// code to set up the GUI using invokeLater(), new Runnable()
}

}

Anyway, many thanks to you guys, you've both been very helpful.

BestJewSinceJC 700 Posting Maven

No, there is no loop. Since a call to pack() re-shows something thats been hidden or disposed, what must be happening is that I'm ending up w/ multiple copies of the same window on top of each other.


So basically I have to either switch from a static variable to a normal one, or simply stop re-creating the entire GUI and just update the information thats currently in it.

BestJewSinceJC 700 Posting Maven

I'm saying that whenever the user clicks on a certain JButton, I'm displaying a list of Teams in a GUI, lets call it firstWindow. So once the user clicks 'X' the GUI disappears. But when they go back into it by clicking the JButton again, it reappears again. Each time it appears, it is doing so through createAndShowGUI. On the GUI I have just mentioned, there is another JButton to show the team's games. When THAT Jbutton is clicked, the number of windows it displays is EQUAL to the number of times I opened and closed firstWindow. So it would seem that my method of 'updating' the GUI by closing the window, then re-displaying it, is not an acceptable way to do things.

BestJewSinceJC 700 Posting Maven

Also, please note that this problem is one I have been having for all my GUIs, not just the JTable one in particular. What I would LIKE is a way to simply 'delete' the GUI from existence, then simply re-create it using createAndShowGUI. I have been trying to do this using frame.dispose() and frame.setVisible(false), but these things do not seem to have the desired effect...

BestJewSinceJC 700 Posting Maven

Ok so lets say I have any GUI that needs its contents changed while it is running, so that it will re-display the new contents. An example would be a JTable that just lists things from an ArrayList. So if I had an ArrayList<GroceryList> my JTable might have

Cheese
Crackers

But once the user highlights 'crackers' and clicks delete, I want the JTable to re-display and just say Cheese. I have been doing this by doing frame.setVisible(false) and then using createAndShowGUI(), but this does not seem to work as planned. Note that my JFrame is a static variable and that createAndShowGUI is invoked using invokeLater() and new Runnable like Java Sun suggests.

BestJewSinceJC 700 Posting Maven

Could this be because I'm using the wrong ways of updating the contents of the window? Because when the window is closed, its DISPOSE_ON_CLOSE. So when its reopened, how do I update the contents so that the new Teams that I want are displayed... ? So far I was doing it by simply re-calling createAndShowGUI, but this must be the wrong way to do it

BestJewSinceJC 700 Posting Maven

Hmm

Actually, I just found a relationship between the number of times that window is displayed & my code. The amount of times that the window which displays all the teams is closed and re-opened, is the number of times that a Team's games are displayed when I click show game stats.

WTF

BestJewSinceJC 700 Posting Maven

Errors - Syntax/compiler errors, Runtime errors, Logic errors

There you go. Now you can look them up and learn about them on your own.

BestJewSinceJC 700 Posting Maven

Step one: Read the whole string in all at once. This can be accomplished in a lot of different ways. If you're getting it from a file, you could use Scanner input = new Scanner(new FileInputStream(yourFile.txt))); Otherwise, if you're reading it from the keyboard, Scanner input = new Scanner(System.in);
Step two: Read in the entire String using String wholeLicense = input.nextLine();
Step three: (There are a number of ways to do this). Make a for loop that goes through every character from the String, then read it into a new String IF the character isn't whitespace. You can figure out if the character is whitespace by making a new Character object, then using the isWhitespace method.


Now you have a String with all the chars you need but without whitespace