Samuel Weston

Ranch Hand
+ Follow
since Oct 24, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Samuel Weston

Hello there. I need to make a program that keeps track of peoples names, allows you to add a note to each name and preferably would reorganize whatever you put in by date or by spelling.

My question then is this, where do you suggest I start looking for a program similar to what I'm looking for (I suppose the phonebook application in cell phones is a good match, a supermarket's list of foods and prices would work as well).
As well as, what do you identify as the key points I'm looking to research/program (I'm thinking I'll want to lookup making a list, GUI's for lists, and code for organizing said list)

Thank you for your interest
9 years ago
Ah! Yes, I thought so. I since made a Window class to reflect the programs needs. Thank you
And thank you all for the recommendations on the naming conventions. I am now aware that they're an offense to the eye.
I'll take your advice into consideration in the future.
9 years ago
Hello, I am creating a user friendly program that allows the user to adjust the dimensions of an oval (painted onto a window) via a 'slider'
Everything is fine for the most part, except in the main code- when I tried coding for a window object for some reason java didn't recognize the type
(that is, I used the keyword TheWindow and java didn't recognize it) the following is the full code set across 2 classes, but I think the problem is centered around the main class.

I took out my comments to keep things neat- but I don't know for sure if I erased anything important.

thank you for your help




the following is 2 of 3





finally, the following is 3 of 3 (the main class)
9 years ago
I'm learning how to create java applets, however among the things being taught, is how to transfer the compiled program from your computer to the website server.
Problem: I don't own a website.

My goal is simply to test the applet to see if it appears on my web browser. Second to that is actually moving the program from computer to server.

Are there any free web domains or places where you can get a free website (even for a limited time) so that I can try out this applet on the web browser? Or perhaps a program that somehow recreates whatever it is I'm trying to test?
Any ideas or suggestions would be fine

Thanks for your help
9 years ago
Welcome Idan! ^^
9 years ago

Sooraj Rajagopalan wrote:The List, maps, set, SortedSet in java (also known as collections) are all interfaces. And everytime you use the collections, the Interface is implemented. In this example, now that you have narrowed it down to <String>, the implementation of the interface "List", stores String.
Now consider the following


The same thing happens, which is the implementation of the interface. Only that list1 stores Lists(which store String).
Hope it helps than making you all the more confused. cheers!!




I really appreciate your response (I honestly mean that). Just to make sure, with <String> I am telling java that of all the data types that you have, I want you to use String.
Correct?

Thanks again

9 years ago

J. Kevin Robbins wrote:Those are called Generics and it makes sure that you can't store anything else in that collection except what you've declared, in your case, a String. The advantage of this is that it turns a possible runtime error into a compilation error. Without the generic declaration in there, the code would compile and run and wouldn't blow up until your code tried to store say an Integer. By declaring the type with a Generic, the compiler can catch the error before it becomes a runtime problem.





Thank you very much for your response. You've given some things to think on, but I understand it now. Much obliged
9 years ago

Stephan van Hulst wrote:If I wrote a class named ListIterator, how would your application know to use the standard ListIterator and not another one?



my update to my question should answer your question. I appreciate your time .thank you so much
9 years ago
I'm supposed to write a program that
1)has an array of Strings that is then added to a List -and outputting that List
2)remove certain Strings in List1 by using a second List -and outputting the result
3)and finally, reverse the order of the Strings outputted in the last result

Problem: Eclipse is telling me that I have not imported the correct method for this program and the output is an error
.
After this, I imported the suggested import that Eclipse gave me, with the result being that I only outputted 1)and2) as a single line

What am I missing?

(Note: the "problem method" is ListIterator (all the way at bottom ListIterator<String> william = L.listIterator(L.size());
eclipse says "ListIterator cannot be resolved to a type"
and suggests (among other things) I import ListIterator.util (but doing so outputs 1)and 2) as a single line)

UPDATE: after going over the code yet again, I realized that what I thought was the problem was actually something else entirely. In case you're wondering (and because I think learning from my experience
could help someone in a similar situation): one of the pieces of code that I wrote was in fact an obsolete piece of code that I somehow copied to this class.
in addition, this piece of code resulted in an output similar to what I was looking for -in regards to the program as a whole.(the code removed certain String words from a List by using another List
-meanwhile, I was trying to remove certain words from that same List via another technique (just fyi: I also incorrectly construed my second goal ("2) above")

The Fix: I removed the obsolete code, and then proceeded to and succeeded in fixing the code with the correct "method"

9 years ago
sorry- I know this is a simple question, but I forgot the answer

Im making a simple code to add an array to a List


(the code im referring to is <String> )


my simple question is - what are the <String> ...<String> for?
I understand it makes the list1 variable a string, but why is it made like this?
do we usualy use <String> when we need to make a variable a String?
9 years ago
I'm making a program to demonstrate Exception Handling.

(note: the code was written inside towards out)
The user is prompted to input two values (integers) and then the program will divide those values and output the result.

I then added the "try" and "catch keywords for exception handling-instead of the program shutting down if an error occurs,
the words "you cant do that" will appear

I then added a while loop to allow the user another chance to input usable values. Of course, I made sure to make a termination to the loop as well.

Everything works as expected if the user inputs e.g 8 divided by 0. in that case exception occurse, the user is told "you cant do that", is then prompted to start over and so forth until he gives usable integers. then the program continues to the termination
However, if the user inputs a String , e.g 9 divided by xyz, then the program goes into an endless loop

My question is:

1) why does a String cause an endless loop ( I have a theory)

2)why does the loop occur as soon as I put in an incorrect value- is the while loop somehow in extant? somehow always waiting? (hard to picture it)

3) lastly, what would be the correct code to handle and exception caused by a String (as opposed to being caused by impossible to execute math)

here is the program

(and thank you so much for helping)
9 years ago
okay,I created a program that demonstrated an array holding a number of objects, each from different classes.
the printout I got for the first program ended up being gibberish. when I made the program a second time, I got the correct result.

I've been trying to pinpoint the anomaly but I can't seem to find it. So ill try breaking down what I did and maybe you guys could help me out?

Goal:
The purpose of the program was to have a single Class (we'll call the Class 'Animal') to pass the parameters of a previously made method. This method would, amongst other things, call on an array.
Further, I would then make subclasses of the Class Animal, and then use them as well to pass the method parameters, thus demonstrating subclasses can be used in place of the super class.

3 of these classes were made purely to as a "place setter". the Classes called "Cat" and "Dog" respectively were created to be subclasses of the Class Animal (with no other code inside them aside from "extends Animal)
the 3rd "place setter" called "ClasstoHoldObjects" was created to be the array class (ClasstoHoldObjects itself has no code in it aside from the class name)

these are the ones we want

Animal class (which holds the coding meant to be used)
Here is the Animal Class




and then I made a Class to execute everything



the print out was this

next, im putting THIS line in the array... june_6.Dog@a0dcd9


(and the same by the Cat object)

Notes: I recognize june6 as the package name.

I didn't include the 3 other classes nor did I include the correctly executed version of this program to save you guys some time.
if you want them please mention it

This is the first time I used java code brackets for a post -I hope it came out alright.

finally, I erased extra lines as well as comments and simplified class names to make the code more readable. If you want the original, or some class names are a bit off- I could give you the original with all its comments and longer named classes

thanks for your help
9 years ago
I don't know of a book- but thenewboston channel on youtube goes through java -from the basics to more advanced stuff- with eclipse

here's a link to the first lesson https://www.youtube.com/watch?v=Hl-zzrqQoSE

good luck. and welcome to the forums
9 years ago
alright then. I really appreciate the feedback and advice. I'm setting this question as resolved
9 years ago

As far as I can tell, programming can and does apply to practically every aspect of modern day life. That being the case, I have been wondering -since I can't find anything in my research- if you guys would know how to choose what field to pursue. That is, I know programming is in the media, machines, public resources...but these terms are so vague as to be practically useless (media could include web programming...but does it include computer games? or should that be under machines?). Is there a way to narrow your choices? For example a site that lists the major categories then lists the subcategories and then the specific job? A book that writes out the specifics of the programming environment? Or perhaps, you yourselves have some advice?

Also, how do I find an internship? (Oftentimes, an internship is available in your local community-but how do you find that out?)

Thank you for your time
9 years ago