Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!

Les Morgan

+ Follow
since Sep 29, 2015
Les likes ...
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
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 Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Les Morgan

Every class implicitly extends Object, unless you are explicitly extending Object. All classes are derived from Object.

Campbell Ritchie wrote:

Les Morgan wrote:. . . A sub class is any class that is derived from an existing class: so see "extends".


. . . but don't forget that every class implicitly extends Object if you don't specify another superclass with extends.


I am not sure what you are saying:

There is a very simple equals Override for Object , so simple in fact that it does nothing except return true for every case.  Could you please give us a small example of what you have tried--an example of what you tried works much better than my crystal ball does at this time.

A sub class is any class that is derived from an existing class: so see "extends".

Remember in my original reply I said it was "when" and not what is happening.  In Java and many other languages the increment operator "++" is used in a special way--if it is before the variable it is called a pre-incrment and if it is after the variable it is called a post-increment.  The problem you are having is not in understanding the loop construct, but the expression "i=i++". What you think is happening is the same as in "i=i+1", and that is NOT what is happening.

First the assignment operation is done: "i=i" so now we have i set to the value of i, no big deal, but there has not been an increment done at this time, Java has not even considered the increment yet, but the left side has evaluated already to i, that same value as when it started on that expression. Now after the left side has been evaluated the post-increment comes into play to evaluate the right side of the expression and it 1 is added to the value of 0 which is what i is in evaluating the right side of the expression, so the right side has been evaluated to 1.  All well and good, but that has been done AFTER the left side has been assigned the initial value of i, which was 0.  That is what is called POST-INCREMENT. The incrment happens after the use of the value of the variable.  

Not if you put the incrment operator "++" before the variable, that is called PRE-INCREMENT and this happens for "i=++i", i looks to be assigned, Java encounters the pre-increment and says--before the value can be assigned to the left the pre-increment has to be honored, so the evaluation becomes i=1+0 and is assigned the value of 1.

Since in the loop example you gave a post-increment is used, then the value of i is carried forward in the evaluation of the equation "i=i++", hence i is never incremented in the loop, and therefore the loop is infinite--never proceeding past a count of 0, but ever looking to become 5 or more to stop.

consider the following:

The example illustrates post and pre increment operation.  If you are going to use pre or post increment, then you need to understand "WHEN" the increment happens, because it can make a huge difference in evaluation.


Veena Pointi wrote:Below is explanation of OCA by Jeanne Boyarsky and Scott Selikoff for sequence of executiong of for statement

1.Initialization statement executes
2.If booleanExpression is true continue,else exit loop
3.Body executes
4.Execute updateStatements
5.Resturn to step 2

So you see i=0 happens only once.As per this explanation both code blocks above should output same thing that is print 1 2 3 4 . Why in case of infinite loop , i is being initialized to 0 everytime and why not in other case?


I am unsure what you mean by this: "i am getting error : Connection reset (when i create a stand alone jar and run it all is fine) "

Are you saying when you compile down to a jar and execute the program everything works fine, but then you try to run a debug or from your IDE your connection is reset?

2 weeks ago
must Janik,

you need to look at try/catch/finally  blocks:

put your operation for date conversion in the try and then you can do your reporting errors in the catch block, the finally can be unused.

2 weeks ago

You have to look at what the "++" operator is doing, and when it takes place--the when is the key:

"++" is the auto increment, as a lot of people call it, but in reality it is the "post increment" feature of many languages.

The "++" operator happens only after the function is complete, so i=i++, goes to this i=i; i++. For the context of the loop i starts as 0 and each time through the loop it is assigned i, value of 0, each and every time through the loop. The "++" happens after the assignment happens, so you never see it take effect in the loop.


It looks like you have a homework assignment that you need to write data to a column format according to how they are presented according to a date. Is that correct?

Please post all of the instructions you have concerning the homework so we can know what parameters you are trying to work within, otherwise you are, at best, going to get answers that are worthless for your class purpose.

2 weeks ago
Look in the API under "all known implementing  classes" and try one of the Ellipses.
1 month ago
You make a method to change the color in your class, and expose it so others can call it.  Your objects should control what happens within themselves, but you offer that method with proper visibility for your project to facilitate the changes needed from other location.
2 months ago
You will want to use fixed width mono space fonts, the system font in Windows would work, if you are going to print them out to System.out
2 months ago
Just another comment as my brain starts to turn some of the old rusty wheels...

Several years ago, back int he day when Sun ran Java, there was a discussion on what one of the contributors called "stupid code".  Stupid Code is a venture down that ego-less path, you acknowledge that the JIT Compiler used in Java is probably going to be way better at optimizing code than you ever will be.  Think about it: Java is translated into byte code, so your job as a programmer using Java is not to write "the coolest code ever", but rather, to write the most classically simple code understood by the compiler, so it can make it the fastest thing on the planet.  Who really is to say that the optimization path your are running down is really an optimization path?  Ultimately it is what the JIT compiler does with your source that makes the real difference.  If the JIT compiler cannot optimize your code, your "optimized" code is probably not really optimized.

We no longer live in the world where we have the C compiler and to get it to run faster we do an "asm" block and put in assembler codes that we know to be the absolute fastest way to do something.  Now we write our source and submit it to the JIT Compiler hoping the byte code in that JAR has been understandable enough for Java to make good with it.
2 months ago
In all of my career I have developed solutions using as fundamental of code as possible, for me this is ego-less programming.  I have a coding style that I expect new programmers to be able to understand as soon as they set foot into my shop.

I have worked my entire career to promote others to adopt this type of style, where it is plane, simple, and understandable, that is not to say, that elegance is not sought, but rather, understandability, completeness, and maintainability is promoted at all levels.  Programmers are discouraged from obfuscating their code by using "tricky" or complex coding.  This is a far different philosophy than I encountered when I first entered the market out of college, back in the day, often a programmer would make code complex, dirty, or spaghetti like that nobody wanted to maintain it.  The programmer perpetrating this onto an enterprise would do so as "job security".  Nobody wanted to look at their awful code.  This is a catch 22, since nobody wants to read that programmer's code, that programmer is in a dead end job, maintaining every piece of garbage they spewed out into their surroundings.

To make code that anyone can understand does require you to put away your ego and accept a roll more as a tool maker for the greater good.  It has paid off for me in many advancements, projects, and pay raises.  Not to mention that since everyone can read my code, I am free to take on new projects and not have to worry if Joe over in the other group that I just left can handle maintaining my code while I go on to bigger and better things.
2 months ago

In your code and my code, the 1 is autoboxed as a char corresponding to the nonprintable char with numeric value of 1, not '1'. When it is cast back, you can see the value has not changed.
Tim Moores,

Ya, I have been waiting for the other shoe to drop with Oracle "managing" Java. Sun was a company I could go and talk to the engineers, Oracle, on the other hand, assigned me a "support tech" in India that was asleep while I was working and I was asleep while he was at work.  I think they pretty much sums up Oracle's service.


Tim Moores wrote:Just found this little post about a newly introduced problem with backward compatibility:

That kind of thing didn't used to happen.

3 months ago
All I know is that of the $90K we paid Oracle for support over the life of our project, they answered ZERO questions, that is right no help what so ever, and because they could not render any support I did not allow them to ever close a help ticket, but they did anyway and without my permission and without ever providing an answer.  This resulted in us switching our enterprise from Evil Empire Oracle to Evil Empire #1 over in Bellevue.  At least we get the kudos of our governor now since we support the local boys.

Tim Holloway wrote:This is the annoying thing about commercial software today, and one of the biggest reasons why I avoid commercial software as much as possible.

Commercial vendors like IBM, Oracle, and the like used to provide a lot of support for the admittedly astronomical sums they charged. When we had an Amdahl mainframe, Amdahl actually set up a local office right in our building. IBM had a whole building by themselves (and a very good Arabic sandwich shop on the ground floor).

But when we adopted OS/2, it was almost impossible to get support for it. And every time we found a good IBM support person, they ended up leaving IBM soon after. I was frustrated, because I'd bought my first Linux distro for the princely sum of $35 for 2 CDs and I could get more assistance from both the Linux OS itself and from online forums than I could get from Fortune-50 IBM for OS/2.

So IBM, Oracle, et. al., went to horrible phone queue systems with under-qualified software support (this is when the cliché phrase "Have you tried turning it off and back on again?" appeared), and the preferred support channel is to go to their forum system, which typically is getting half its help from unpaid volunteers and which rarely comes up to the quality of the wholly-volunteer sites like JavaRanch  or open-source product forums.

If I'm going to pay tons of money, I think I expect something better. Or I might as well not bother. Most of what Oracle can do for me I can do with PostgreSQL. And probably a few things Oracle can't. Commercial products these days are designed by marketing droids and implemented almost entirely by cheap offshore labor. Open-source projects are usually done by people who actually believe in what they are doing and are generally better-skilled as well.

3 months ago