Nick Fio

Greenhorn
+ Follow
since Aug 05, 2012
Nick likes ...
Eclipse IDE Firefox Browser
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
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 Nick Fio

Hi Sam! This is my first attempt at helping someone else here ... EVER!

You understand that a constructor constructs an object using the stuff inside of the curley braces as the blueprint. And you understand that a constructor can be used to construct one object, two objects, or a gazillion objects.

You've got to keep in mind that all of that stuff about the scope of a variable that applies to methods and loops ... it also applies to constructors!

The keyword this means that you want this stuff to apply to this instance of this object.

Suppose that you had instance variables (aka, fields) named gameName and priceEach, and that your constructor parameters were also had the same names. Code like this ...



... would NOT end up assigning what was passed into the constructor to the object's fields. Scope!

But if you use this ...



... the the Java compiler says, "Ohhhhh ... dude wants to create a Game object whose fields are these values!"

Your first example is fine. An alternative to it is using the keyword this like I did previously, which has the advantage of you not having to create new names and to mentally remember that these names refer to same thing. It's a pretty nice feature when you get to writing more and more complicated programs and don't want to keep racking your brains for new and creative names for the same thing!

Your second example is kind of redundant because the compiler can figure out that you want name to be assigned to gameName and price to be assigned to priceEach without this.

Hang in there. this gave me fits when I first studied it.
10 years ago
Hello all!

I'm an older guy who has gone back to school and I'm currently taking Linear Algebra. The class was given an assignment last week: Write a paper in which you use the concepts of Linear Algebra to solve a problem in your field.

I don't have much experience with Java or programming in general, and with only five weeks' exposure to Linear Algebra, I'm very green in that area also. So I am completely stumped.

Any ideas? I can write the paper, but I sure could use a kick in the right direction!

Thank you for your time.
11 years ago

Suhas Mandrawadkar wrote:
The Android application project wizard was changed in last version of ADT.


Thanks Suhas!

Ah! Ok. So it looks like I have to make a choice here: 1) If I want my stuff to look like the book's author, I need to get rid of the new ADT and the new SDK and replace them with older versions; or, 2) Learn to do stuff with the new stuff.

If I choose the latter, how do I import a non-Eclipse Project such as the book author's sample projects (from here) and create a project from an existing source?
11 years ago
I'm trying to teach myself how to write an Android app via books. For both of these books, I'm finding that the instructions and the pics in the books don't quite jive with what I'm seeing on my computer.

I'm currently trudging along through Grant Allen's Beginning Android 4 and the task at hand is adding Android project files to the Eclipse workspace. The instructions are, "First, choose File ➤➤ New ➤➤ Project from the Eclipse main menu..." Ok. Easy enough. His picture looks like what I'm seeing on my screen (always a good sign!).

But then..."Then, choose Android ➤➤ Android Project from the tree of available project types..." When I do that, there's an "Android Application Project," but no "Android Project. That's gotta be the same thing...right???

And then the wheels come off: "Then, on the first page of the New Android Project wizard, choose the “Create project from existing source” radio button, click the Browse button, and open the directory containing your project’s AndroidManifest.xml file." There isn't any radio buttons and the book's image looks really different from what I'm seeing on my machine.

Thinking that the book was perhaps written before Juno was released, I installed Eclipse Indigo and followed the instructions; however...the same thing. And I had this same issue with another book that I was working with.

So what causes the discrepancy? Is it because the author is perhaps using a Mac? Does it have something to do with with me using a newer SDK? While I'm learning, it would sure make life easier if my stuff looked exactly like the author's.

Thank you!

11 years ago
I hadn't thought about treating polynomials as objects. What I had thus far was procedural. It seems like I would need test for and then instantiate an object for a polynomial of type ax^n + bx^n-1 ... + c; another for composite functions which use the Chain Rule; and somewhere along the way, have something that replaces trig functions and inverse trig functions with their respective derivations.

In searching around online, I am shocked that I haven't found previously-written source code for similar projects. What I have found has either been very basic (I found a polynomial.java that uses the Power Rule and only works for positive powers) or various libraries that seem geared towards Java professionals whose home address includes the word "cubicle" and math PhDs in labcoats. There ain't much in between.

I do have the GUI separate. It's the only part of my code that doesn't look like a steaming pile of fail.

Thanks!
11 years ago
I have just finished two quarters of Java programming in college. I thought I'd kill two birds with one stone : I could continue improving my Java skills by writing programs which pertain to the upcoming quarter of Calculus (the multi-variable kind). I've got some spare time, so I started writing a program to do single-variable differentiation and integration.

Currently, I have a really nice GUI in which I enter a function in a JTextArea on the left, I select a JRadioCheckButton for "dy/dx" or "integrate" in the middle, and a JTextArea on the right side gets the solution after the Calculus class gets done. The Calculus class takes the expression in String form, iterates through it, and puts coefficients, variables, exponents, trig functions, and ln each into indexes in an ArrayList<String>. If "dy/dx" was selected, my Calculus.java can successfully apply the Power Rule (if the exponent is positive). The Chain Rule...Implicit Differentiation...all of Integral Calculus...I think I'm getting a headache...

In a nutshell, my program looks like a hot mess of nested ifs and a 50-line Switch statement just to get the expression into the ArrayList<String>. It's Rube Goldberg: Java Programmer.

My goals with this project, as I mentioned, are to use Java practice as a way of reinforcing what I learn during the course. Between now and when the quarter begins, I want a program which can do all or most of what I've learned thus far, and then I can mix in the stuff I learn as I learn it.

So...what should my strategy be? How do I use these libraries that are out there such as Apache Commons? Where I can find discussion of similar endeavors, TreeNodes seem to be the preferred tool; why is that?

I would definitely appreciate any help I can get on this. And, if anyone's in the Seattle area, I'll buy ya a beer sometime!
11 years ago

Alan Shiers wrote:You were right. That was it. I wound up going to the JDK 1.7 javadocs and downloading their stylesheet.css file. I put it in a special directory within the JDK1.7 folder on my hard drive and referenced it from Eclipse. Never had to do that before, but it worked.

Thanks,

Alan



First time poster here.

Thanks for this thread! I had just upgraded to Eclipse Juno and my javadocs for Java 7 were looking exactly like the pics posted above (Java 6 was looking normal though). Here's the link for the stylesheet...

http://docs.oracle.com/javase/7/docs/api/stylesheet.css

Since Google doesn't provide many helpful links on this particular issue (that, or my Google Fu is weak sauce), here's more wordy solution that worked for me:
I copied the linked-to file above into a text editor, saved it as stylesheet.css, and put it in the jdk1.7.0 folder. Then, when generating a javadoc on Eclipse, on the second page of Javadoc Generation, I clicked "Style sheet" and browsed to the file I had just dropped in there. Now my javadocs have Java 7 goodness!

Thanks again Alan!