Stephen Davies

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

Recent posts by Stephen Davies

I would just like to make a personal comment about the example Saibabaa gave. I haven't come across it on ExamLab, but I hope I don't, it has to be one of the most convoluted examples I have experienced, it took me 15 mins to figure out what was going on! Perhaps its just my slow mind Yet goodness, its a humdinger of a poorly written program (in my opinion of course )
Put simply (in my eyes) Your ternary expression appears to be assigning a boolean or an integer to a String reference variable, thats all.

Nancy Antony wrote:how to prepare for scjp 1.6 to score above 95% marks?

Why would you need to score so high? Of course it looks good, but don't forget to actually learn something on the way!
Well I don't think its supposed to be too easy. However, I'd like to share my experience in the hope that it may add to the wealth of advice already available here.

I am more in the belief that some time submerged in Java in some applied capacity will facilitate a better understanding of Java, its practical application and hence a better approach to the exam. Let me expand;

A few years back I was completely self taught in Java, from books , the Internet and writing copious amounts of code in practice. I took the SCJA after about 9 months and scored high, which gave me a boost and encouraged me to go for the SCJP. I continued to revise for about 3 months and then tried to sit it but scored just below the pass mark, despite scoring OK in all the labs and such like. Not being one to be discouraged I hit the books again, and was fortunate enough to then land a job based on my SCJA and self taught skills. Two years later, I am now a senior programmer of sorts and I am aiming to take the new SCJP exam next year. From my experience of writing and being involved in using Java for real applied programs, from small apps to Enterprise services, my perspective and understanding has increased hugely. I feel far more confident in taking the exam, and my knowledge is not just theory based on books and reading.

Now I know, there are many people who have and can pass the exam based on the books alone, but for those of us who are not in that mould, I recommend taking a step back and prioritize your learning, if there is any possibility you can get practical experience in java before you take your SCJP then do it, even if its an open source project contribution you will benefit so much, you will not just get many of those "aaah I see how it works now" moments but you will get the bigger picture as well as subconsciously getting a lot of the dreaded API firmly impressed on your brain. I couldn't grasp the collections framework at all before my job. Since my employment we use it all the time, and now its second nature to me, even generics are coming easier!

It's far harder to try and get it the first or second time round from just reading a book, even writing examples, but if you need to use it and are involved in creating whole finished applications then it starts to become clearer. Of course there will be people who may need SCJP to get that job position or experience, but its not a prerequisite for all jobs, and there is an increasing amount of need for voluntary contributions to open source projects on the web. If it is at all possible to get that practical experience do it, and then such things as API memorization are not such an issue. Of course, its impossible to get experience that covers everything, so its not a replacement for reading and test code writing, but it does compliment it tremendously.

Just ask yourself, why you want your SCJP so quickly, is it necessary to go for it straight from the book, are you learning or just memorizing? If your only memorizing, the exam must have not much value to you in the future. Yes it looks good to a prospective employer, but even better than that is the ability to understand, and utilize what you have learn't from the exam. I f you have just memorized lines in a book, then you may well get into a bit of a stick if you ever have to use that knowledge, even if you get in the high percentile this can mean nothing in the long run unless you can show you understand and can use that knowledge.

My personal mantra in regards to learning anything, I liken to learning a new language; "its one thing to learn to speak a new language, but to then think in that language is a different thing". Thus its one thing to learn Java, its rules and principles, but its another thing to know how to apply them and use them in reality. I wish all potential SCJP candidates all the best in their exams, keep using JavaRanch its by far the best forum on the net for Java, and for reading certainly Sierra & Bates has to be the first in your library, code code code, butif you can get involved somehow, do!!!

I hope this small precis can be of help. Of course its not the same for everyone, but for me it has helped my development into Java immensely considering my academic background is in Environmental law (PhD level).


pete stein wrote:Can you show code that demonstrates this?

Hope this can be of some helpĀ 
a byte is also an int (just smaller in memory). b1 is a literal and refers to an integer type so the compiler is getting confused as to which method to call. I think there is some implicit conversion going on or similar. Of course I may well be off, but that's my understanding.

Generics can get a little sticky and confusing. All I can suggest apart from keep writing code to test your understanding, is to read read read. Particularly helpful for me was the concept of Upper and Lower bounds. That is the and generic references.

Just a little tip for ya, good luck

Abimaran Kugathasan wrote:My Advise : UseRealWords

I think you meant "Use Real Words" as 'UseRealWords' is not a real word !
Hi Saibabaa,

Prasad has done an excellent job of outlining what happens, however I had to go through it myself in order to fully grasp what is going on and I have tried to simplify, or at least re structure the comments, and re-implement the code, with more verbose naming conventions, for my peace of mind, to try to follow the logic. If it may help I've posted my version here. Anyone feel free to correct me or comment if I have got it wrong. My comments try to show my understanding of whats going on.

Given the following code

..and given that "test.txt" is in the same folder/package/location as the generated .scala file. I recieve the following error: (I have hashed out the package names as they are private company ones)

...however, if I paste the full path to the location of "test.txt" the application works. This is certainly not practical, by any means. I am using Eclipse, could it be an IDE issue, or should I be able to avoid providing the entire path to a file if its in the root location??
13 years ago

mohamed sanaullah wrote:You have declared the private function- lg(). But you need to invoke it to get executed.

It works now, many thanks. I can grasp the need to provide a call to lg, though when you say it is a private function I am confused. I'ts a local function object to the outer function, and despite being inaccessible to outside code (as in java) does this make it private as in the meaning of the access modifier? , I was under the impression that non declared access is public by default in Scala. unless otherwise declared. Hence, getMyName is public and that lg() is a local variable to it (within the inner scope only) and is simply implicitly inaccessible to code outside the getMyName function but not "private" as I have not declared it expressly so.

My question is more semantics than anything else, but I would like to clarify the situation.
13 years ago
I am a Java developer, learning Scala and I have just begun to look into nested functions. Whilst I understand the concept, I am still confused as to how they actually work in the code. Take my following example:

When I run this, I get no output whatsoever. Shouldn't the String I pass to the top method call be processed by both functions, and hence print out? Am I missing the bigger picture here?

13 years ago
Is it just me or is there some deep rooted issues with running Netbeans 6.9 on Linux? I have floundered on multiple issues during my fx development project, all of which I will not recall here. However I would like to put out an SOS to the community in the hope that help may be at hand, especially since Google is becoming increasingly.. well awful at returning relevant information, even with advanced searches.

Running Netbeans on th latest Ubuntu release, all is well in my project code fine, mysql database found etc etc. At a first run, I can successfully map a ListView to information in a table on my database (using the Netbeans composer binding wizards). However trying to bind using a cellFactory to bind to the items of the list view to the exact same data Source (of course removing the original binding) throws a moan about returning an object when a record is needed. Fair enough but my converter selected from the bind wizard is (asReord).getString(), so how it thinks its a raw Object, I have no idea.
To put it in clearer terms here are a few code snippets.

If I repeat this process without the listCell and simply bind all records in the dataSource to the ListView with the Records[] > String[] conversion all is well. I would choose this if it were not for the fact there seems to be no other way to format the style of the listCell items, nor add an action on each one without using a listCell.

The most confounding thing of all, is if I try this at home on my Mac, it works! Go figure!

13 years ago
I'm at my wits end. I am developing an in-house application in JavaFx using Netbeans 6.9 and its Fx Designer tooling. All is well with the UI design, however, I have come across a problem. In Netbeans, I create two fx files (essentially two classes with their own stages, scenes and States etc) through the use of the design and source views in Netbeans fx Designer. The classes are named 'Login' and 'Homepage' respectively. In the Main.fx file which I selected to be auto-created when the fx project is created in Netbeans, I set the run functions design variable to point to the Login class, which then gets its design file accordingly. When I run all is well I can see my Login Class OK and the window is shown.

I have created a Login button and form that receives user credentials on this login view which will check the credentials entered against a database, but for now the login button function is intended just to open the Homepage view, and herein lies my issue. How on Earth do I do this?? I am not using scenes, I have a Hompage.fx file which has its own class and Stage, but in Netbeans the default Stage and class cannot be altered (in this case the one in the Login Class). I have tried many different approaches, offered by Good and awful examples stemming from a Google Search.

Pragmatically I need to create functionality in the login function which creates a new instance of the Homepage Class and then runs the stage in that class, closing the login stage (or at least removing it from memory). The issue seems to be exacerbated by the auto generated code of Netbeans, which is a double edged blade for me as I need the drag and drop designer to save copious development time(IM the only developer on this project) but on the other hand it seems in this case, to be obfuscating my ability to customize the code I need.

I would love to print out all the code here for a better context but there is much auto generated nonsense which would confuse things, however I will try to give a pseudo outline.

13 years ago