[hotjoe.com] HotJoe Java Help Forums
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Visit java.com
Missing post? - see this post about spam for more information.
Messages posted by: stdunbar
Forum Index » Profile for stdunbar » Messages posted by stdunbar
Author Message
Are there a fixed number of numbers in each set? So, if you used String.split() could you say that, for example, elements 0-6 are in the first set, elements 7-12 are in the second, and so on.

You need some way of delimiting, either a character or a count.
I've recently switched the hotjoe.com domain to use Google Mail. I'm questioning that move now that Google silently blocked emails from "forums@hotjoe.com". I've fixed that but you may have not gotten emails when a topic was posted or when you registered. If this is the case, email me at forums@hotjoe.com and let me know the email address you used to register. I'll get it fixed.
I don't disagree. It is strange to me that a Linux system - famous for nothing if not the ability to customize - has been somewhat crippled by a questionable UI. I use Ubuntu desktop but, to be honest, with the introduction of Gnome 3 and Ubuntu's Unity UI, Linux is sliding backwards in the desktop battle. Both Windows and Mac OS/X are easier and more customizable.

However, since you're developing in Java it doesn't matter - use the O/S that you like and go from there. Of course, be aware that your program may run on other operating systems. If you need to use Runtime.exec(), remember that not everyone is on the same O/S. Also, if you need to create a file on a path, use a config file so that it can be changed depending on your setup. Otherwise, Java makes it pretty easy to develop in a cross-platform way.
It might be easier with an example:



and



Outputs:
first object, named "I am the first one" has been called 1 times
second object, named "I am the second one" has been called 1 times
there are 3 objects

So what all is going on here? In the Something class we declare two instance variables and one static variable. Each time a new Something object is created that instance of the Something object gets its own version of the two internal instance variables. These instance variables are, in this case, private to the instance.

The static variable is shared between all instances of Something classes. No mater how many instances of the Something class I create there will only be a single "referenceCount" variable created. Notice that I created a static method to access the static variable and that the syntax uses the class name, not an instance.

You most certainly do not want all of your methods static nor all of your variables static. While this is easier to teach, it isn't object oriented. Note that part of the reason that it's easier to teach is that the main method for a program is itself static so having everything static avoids learning the way that "new" works. But that isn't very realistic - a reasonable sized program needs to take advantage of objects and those objects should use encapsulation wherever possible.
In general I would recommend that you "hide as much as you can" when it comes to both variables and methods. I never create public member variables unless they are final. That means that I may need "getters" and "setters" for some variables but there is no need to expose more than needed.

Protected variables are a bit different. In general you have to think about how an object is going to be used. More than once I've created a single class only to realize that some sort of polymorphism would be better. In that case I have to update a class to have some protected stuff.

The hardest to me to figure out up front is package visibility. In my career I've only used that a few times but it can help with encapsulation.
Actually, it would be easier to have multiple threads than one that spans 10 pages. Can you start a new thread for each topic?
Yes, that looks correct and yes, we've all had those moments. I've been doing this for years and, unfortunately, it doesn't go away
It doesn't matter which version (32bit vs 64bit) - Ubuntu recommends the 32 bit version because it will run on pretty much any Intel based machine.

Ubuntu is one of the many Linux distributions. It is based off of the Debian distribution, itself a type of Linux.

Think of in an object oriented way:



And there are many, many more distributions.

Don't let this overwhelm you. Ubuntu is known as a beginner distribution and is also very suitable for production use. I'd recommend starting with it and seeing if you even like Linux.
I'll help by way of a question. In looking at this line:



what is the variable Cody? And how do you assign a value to a single String variable? Do you need to surround the value with any special characters?

Let us know if this helps.
Well, there are pro's and cons of both. Ubuntu is a Linux variant. As such, it won't run Windows software like .exe files out of the box. There are some compatibility packages but, in general, it's like moving to a Mac OS/X based machine.

I develop on an Ubuntu desktop machine while other people on my team use Windows or Mac. That's a big advantage of Java in that it runs on the all of these platforms. We all use Eclipse as it is available across those platforms.

To be honest, it's a bit of a personal preference - if you're productive in Windows then you may struggle under Linux. As an old timer, I began my development career using MS-DOS and then Sun OS from Sun Microsystems (now Oracle). So Linux was a fairly easy transition. If you're a Windows user you'll understand much of how the new desktop works but, to be honest, it is more similar (now) to Mac OS/X than it is to Windows.

I host hotjoe.com on an Ubuntu machine and use Ubuntu as a host at my "real" job. My decisions have been based on cost (most hosting providers have to charge something per month for Windows as it is commercial and all of the development tools are free), my personal familiarity, and my personal appreciation for the overall philosophy of the open source movement. Your preferences and personal biases may be different.

Ubuntu has the ability to boot from a USB thumb drive to try it out. It doesn't modify your disk at all so if you hate it you just shutdown, pull the USB thumbdrive out, and you're back to Windows. Take a look at the Ubuntu instructions for more information on how to do that.
chowbaaron wrote:I would assume after.

I didn't want to start a new thread as my question is already related to the one asked here:

What is the difference between using Math.random() and java.util.Random? I know Math.random() returns 0.0 to 1.0, and you can specify ranges with java.utl.Random, but why would you use Math.random() when the other is easier to get the numbers you want?


Internally Math.random() just has an instance of java.util.Random. It is just a convenience method.
Ok, so Math.random() returns a double in the range of 0.0 to 1.0. What math do you have to do to get a number in the 0-2 range? A cheap and dirty way is:



That returns a number between zero and 3. I'm not going to tell you it returns the worlds most random number but it does work.

Edit: my first statement is not quite correct as the method returns a double in range 0.0 to less than 1.0. Therefore you'll never get three since the cast to int lops off the decimal places.
The assignment give some good hints. Generate a random number in the start() method and use it to figure out which image to display. The number will be saved in a member variable within the class.

A super simple start is:



This gets the randomNumber generated - there is still a bunch to do.

Take a look at the Oracle tutorial on Applets for a bit more information.
First, it would speed up answers if you could post a SSCCE - what you've posted is just a snippet of code and it takes longer for those that are helping you if we have to put a framework around it.

Next, I'm not getting the problem you're getting. My code is:


This outputs to the screen exactly what is in the .txt file or vice versa, including the zero. I'm using Java 1.6.0_30 in an Ubuntu environment.

Let us know if you are still having problems.
You're missing the syntax of the switch statement a bit. Your code should look a bit more like:



You'll want to switch on the operand character.
 
Forum Index » Profile for stdunbar » Messages posted by stdunbar
Go to:   
Powered by JForum 2.1.9 © JForum Team
This site run by Scott Dunbar of Xigole Systems. © 2005-2012 - Scott Dunbar
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners
hotjoe.com, xigole.com, and Scott Dunbar have no affiliation with Oracle