Daniel .J.Hyslop

Ranch Hand
+ Follow
since May 23, 2005
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 Daniel .J.Hyslop

Hi mark ,
You are correct to say the code that I have written is a bit overweight , and it is. I was still having a bit of difficulty in understanding the concept of strings as immutable objects as apposed to StringBuffer ,which I have used in the actual test program for my tutor assignment.Strings cannot be changed after they are created and initialised . I was testing the behaviour of strings in different circumstances of usage to see what happens . The immutable fact of Strings is not really where my problem lies ,I still have a little doubt as to what effect it has on code and what the outcome will be when used in certain areas.Hopefully this will come with practice, thanks for the advice , as usual all ranchers come in with very good solutions to beginners problems, which I am still.
thanks
16 years ago
thanks guys ,
understood , I have just changed my code sligthly to see how your explanation works I changed the string initialisation
instead of a = "ett"
b = null etc....
abc [i] = JOptionPane . etc

changed it to
a = "ett";
b = ""; etc
abc[i] += JOptionPane etc
This did work concanating the strings with values returned from the JOptionPane , the ouput was

ettFord
capri
16 years ago
static double rint(double d) rounds a double value to the nearest integer value , but still posed as a double

ie ; double d = 49.59888;

double e = Math.rint(d);
//results in 50.0



quote from API
public static native double IEEEremainder(double f1,
double f2)

Computes the remainder operation on two arguments as prescribed by the IEEE 754 standard. The remainder value is mathematically equal to f1 - f2 � n, where n is the mathematical integer closest to the exact mathematical value of the quotient f1/f2, and if two mathematical integers are equally close to f1/f2, then n is the integer that is even. If the remainder is zero, its sign is the same as the sign of the first argument.

Parameters:
f1 - the dividend.
f2 - the divisor.
Returns:
the remainder when f1 is divided by f2.
[ September 15, 2005: Message edited by: Daniel .J.Hyslop ]
Hello all,

I have tried to set up an array to initialise String variables in a for loop .The String variables after being initialised with their values print out fine but when I pass them to an objects(VehicleRecord) constuctor no values are passed . I have then declared and initialised a string , reinitialised it with JOptionPane and passed this to the constuctor and it does pass the value . Could someone please explain what I am obviously missing here , her`s the code :

thanks danny

[ September 15, 2005: Message edited by: Daniel .J.Hyslop ]
[ September 15, 2005: Message edited by: Daniel .J.Hyslop ]
16 years ago
When writing a program as a biginner in java and as a student of java we are all prompted to use a certain style ie;


and yet in most examples I see of the SCJP i see

why the difference in techniques?
16 years ago
Hi adam,
These two links will take you to the two packages that contain the classes that you need to consider Class JOptionPane with showinputDialog method that returns a String , even though you are typing in a number at JOptionPane it is still recognised as a string ,it must be parsed .Thejava lang package (which is imported implicitly) which contains the class, which contains the methods for changing your String input into an int

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/package-summary.html
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/package-summary.html
[ August 31, 2005: Message edited by: Daniel .J.Hyslop ]
16 years ago
so ;
class comp
{
public final int const = 5;
comp()
{
....
}
const is recognised as a compile time constant because it is declared and initialised as a member variable : or

class comp
{
public final int const;
comp()
{
const = 5;
}

not recognised as a compile time constant as this has not been initialised at the same point as declaration

Correct or incorrect?
[ August 30, 2005: Message edited by: Daniel .J.Hyslop ]
16 years ago
A constant is a variable that is declared as final , therefore cannot be changed.I have read in some posts about the term "compile time constant", could someone explain what is meant by this term please?
16 years ago
Hello there,

A question which is probably posed by many newbies to programming . With a lack of experience and no real background in programming of any type, what (in the opinion of more experienced programmers)would be the best way for someone to develop a career in this industry and develop the experienced skills required by most employers. 99% of jobs offered are for people with 1+ years experience or more in a programming capacity. I am taking the SCJP which offers lots of knowledge , but no experience how can a beginner get started?
16 years ago
Hi karthik,
An initialisation block is executed before a constructor .An initialisation block is a block of code that gets executed before an instance of a class is created.So therefore it will be executed before a constructor , the constuctor will be executed next. A static block is only executed once when the class is loaded into the jvm and can be used to access static members and instance variables of a class .A non static block is initialised every time an instance of a class is created this also executes before the constructor of a class
Thanks lads and lassies,
I`ve finally got it sorted ! . Pauline I did try using plain text format and other such enterprises with AOL ,but to no avail,thanks for the link .So guess what ? I changed to Yahoo and first post back :to quote the nitpicker "I`m glad you changed to Yahoo" , well Yahoo! so am I.Thanks all for your input , now it`s 1b or not to B?
16 years ago
hi akshay,
When using inheretence you create a class heirachy each subclass has one superclass >When the program is called from the main method ,in constuctor terms the first one to execute is the superclass .each subclass constructor contains an implicit call to super()(if there are no explicit calls) . so when you changed the object initialisation to c r = new c()the subclasses constructor is calling super()implicitly. if you have a heirachy of four classes one extending the next the superclass will be the first constructor to be called then each constuctor in turn will be called from top to bottom each containing an implicit call to super();
Hi aksay,
Class Base has been explicitly initialised with a default constructor which contains the amethod() method . The RType class has an implicit default constructor which automatically overrides the super class constructor.When Base b = new RType() is run in the main method "new RType()" is overridng the superclass constuctor , so amethod() is being called , but becuase Base b references an object of RType,the amethod in RType is called hence the first line of output.Heres a simple program to demonstrate.

[ August 26, 2005: Message edited by: Daniel .J.Hyslop ]
Hi carol
Ah! OutLook Express ! I used to use that when I was tied to MSN it was great never had any problems . Then I changed to broadband and AOL because of the freebies that came along with it ( I can now see why they have to give things free with it) I tried to change my email preferences so that outlook was my default(which AOL say you can do ) by using IMAP instead of POP3.Four hours later I helped my cat deliver the kittens hence the lasoing problems.Don`t know whether my next trick will work have tried pasting the notepad file as a .txt file rather than a .java file whether this makes any difference I don`t know.

[ August 26, 2005: Message edited by: Daniel .J.Hyslop ]
[ August 26, 2005: Message edited by: Daniel .J.Hyslop ]
16 years ago
Hello Tom and Pauline,
Thanks for the input. It is AOL that I am using, I had set the format to plain text when sending the second attempt,unfortunately that didn`t work . I have found an editor within AOL`s email that set`s text to original text and uses an option for indentation "Quote Style" whatever that does I am unsure. When sending the email`s it makes my spacing look eratic as well(Except for the genuine mistakes ) .Hopefully that has worked.But, hey it`s all in a days buckarooing , lasooing , unfortunately I`m trying to lasoo a my pet kitten at the minute .
16 years ago