Pablo Reyes

Greenhorn
+ Follow
since Oct 22, 2011
Pablo likes ...
Android Java Linux
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 Pablo Reyes

Classes and their methods should have a single and well-focused objetive. Imagine this scenario:

In this example, we can say that Document is not cohesive. The Document class should have all the info related to a document, but not things that are not specifically related to a document, like printing. Its much a better idea to have a public void print(Document d) in class Printer, since a printer is made to print things, and a document is not made to be printed (although it can be printed).

Maybe not best explanation ever, but I hope you get the point.
According to Objetive 1.1 in the official oracle cert page:

Develop code that declares classes (including abstract and all forms of nested classes), interfaces, and enums, and includes the appropriate use of package and import statements (including static imports).



I think it's clear that inner classes are required for the exam. Where does it say that they are not an objetive?

This is the intro for KB chapter 8:

Inner classes (including static nested classes) appear throughout the exam. Although there are no official exam objetives specifically about inner classes, Objetive 1.1 includes inner (a.k.a. nested) classes. More important, the code used to represent questions on virtually any topic on the exam can involve inner classes.



There is no specific objetive about inner classes, but there is one wider regarding all kind of classes with all it forms.








I don't know what I was thinking about when I said that. Of course it does, sorry.

Joanne is right.
12 years ago
When you have the line read in data, split it with the split() method using a space as a separator. Then, loop through the array and reverse each element and print it.



Maybe not the most efficient solution, but it should work (haven't tested it)
12 years ago
You forgot to import Mypack.Protection from SamePackage.java.

The fact that they are in the same package doesn't mean that you can avoid the import part.
12 years ago

Bear Bibeault wrote:== tests for identity. The .equals() method tests for equality.

Don't worry, 100% of novice Java developers makes this mistake at the start.



That's correct, but did you undestand why?

The "==" operator in Java is used to compare the actual contents of a variables, ie. the bit pattern. What does this mean?

A String is an object, so a[i] will be some reference variable whose bit pattern is the "direction" of the actual object in the heap (a String object, with an "W", "L" or "T"). So when you call a[i], don't think that it will be "replaced" by the content of the String objects which is being referenced, instead, it will be "replaced" with some direction to get to the object.



That code means:
1 - Create a String object in the heap with the content "hi"
2 - Create a reference variable a
3 - Fill a with some way to get to the object created in step 1 (lets say a = 01001001110010101010101)
4 - Create a reference variable b
5 - Fill b with the same bit pattern as a (so b = 01001001110010101010101)
6 - Check if the bit pattern of a and b are the same

So, what you are comparing there is not the content of the object, but the content of the reference variable.

12 years ago