|
Nagy Vilmos wrote: You don't need it
in fact, you may need this , e.g. to pass "yourself" to another object or class method, say when you want to subscribe to an event or a service.
FWIW: I do like VB.NET's Me keyword, it seems more appropriate than this .
|
|
|
|
|
The keyword 'this' refers to the current class you are in.
If you write 'this.' while in a class, you can access all members
of that class by IntelliSense.
'this' just means 'the current class'. Sounds logical, yes?
public class MyClass
{
private int age = 18;
public MyClass
{
this.age = 20;
}
}
However, 'this' can be omitted.
'this.age' is the same as 'age'
while in the same class.
Regards,
CSTreval
|
|
|
|
|
It's also used to call another class constructor from a constructor (sometimes called 'chained constructor calls'):
class Foo
{
public Foo()
{
this(0);
}
public Foo(int i)
{
}
}
David Anton
Convert between VB, C#, C++, & Java
www.tangiblesoftwaresolutions.com
|
|
|
|
|
It's also used to reference an inner class's outer class - but I wouldn't worry about that yet if you're a novice
|
|
|
|
|
It (this) always refers to the current instances of classes. This function is used in access members of Constructors,instance methods and instance accessors
Qualify Member hidden by similar names and to pass objects as a parameter to other methods this keyword is commonly used.
To get more details click on the given link
Java Tutorial: this Keyword[^]
|
|
|
|
|
is there any means how one can set the print preferences of a jtextpane in the code and print the pane without print dialog?
|
|
|
|
|
print on paper without user interaction? or just setting up a print-view like a PDF-file?
regards
Torsten
I never finish anyth...
|
|
|
|
|
Ive been trying to print both a jtable and a graph on the same paper. anybody with an idea of how this can be achieved?
|
|
|
|
|
I have a function that is similar to the following:
public int LoadFromFile(String fileName) {
FileReader reader = null;
try {
int rval = 0;
reader = new FileReader(fileName);
return rval;
} finally {
if (reader != null) reader.close();
}
} I don't understand why I am getting the compile-time error, "missing return statement". Either execution gets to the line "return rval;", or an exception is thrown and no value needs to be returned. I can get the compile-time error to go away if I move the return value declaration prior to the try block and move the return statement after the finally block (I read online that putting a return statement within the finally block suppresses all exceptions), but I don't understand why I need to do that. Thanks for any help,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
The above code does work. Turns out I had the return statement within a while loop on accident, so if the condition was initially false I wouldn't have thrown an error nor returned a value.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
|
Hi I am generating xml beans for a project at work and I get the following error when I try to run the generated code.
Caused by: java.lang.ClassNotFoundException: schemaorg_apache_xmlbeans.system.s7EDC8529CB4E8F6B440E5C8C61A4B41C.TypeSystemHolder
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(XmlBeans.java:769)
Can someone please help me with this...
Thanks
Stephen
Stephen Lintott Bsc IT (RAU)
|
|
|
|
|
Hello
I don't understand the concept of the following:
Q. "Your immutable system will be compromised if you don't make your classes 'final'."
Can someone explain this to me please (with a concrete example)?
Thanks.
Regards,
Treval
|
|
|
|
|
4 Questions in a row, straight from your course papers?
Sounds like it to me......(i'm in the middle of a uni course at the moment, and its full of questions like this)
Go back and review your notes, or start reading about the topics via google.
Dave
Find Me On: Web| Facebook| Twitter| LinkedIn
CPRepWatcher now available as Packaged Chrome Extension, visit my articles for link.
|
|
|
|
|
|
Think it through. You have a class designed to be immutible. What does marking it final mean?
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
Consider the following text:
Q. "Make the scope of your variables always as narrow as possible,
otherwise conflicts exist in threads; all methods have access to the attribute of the class."
What is the problem with this? What's wrong with having an attribute whose scope is too wide?
Concurrency problems?
Can someone please give me a concrete example in which this problem is explained?
Thank you.
Regards,
CSTreval
|
|
|
|
|
Really simple explained:
if you give access to a variable, anyone who manages to make an instance on the class can access and modify your variable.
So you keep your variables unobtainable to control changes and behaviour of your object.
You give getter and setter to control what your object looks like from the "outside".
You set up an interface to give certain access to some methods.
greets
Torsten
I never finish anyth...
|
|
|
|
|
I don't think it's relating to public/private access, it's relating to scope.
So, prefer variables scoped at method level to variables scoped at instance level where possible. Instance variables are shared across threads; method variables are not. Even if the variable is private, if it is scoped at instance level then two threads could modify it and conflict with each other.
|
|
|
|
|
I agree, this is the view from threads accessing some variables.
greets
Torsten
I never finish anyth...
|
|
|
|
|
Hello
What is meant by the following text?
Q. "public synchronized List (only 1 thread can access it at the same time)"
What does that mean? Does that mean Lists get auto-locked?
Regards,
CSTreval
|
|
|
|
|
The list is synchronized across all threads as described here[^].
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Is this a part of method declaration or what ?
|
|
|
|
|
No it's the constructor as described in the link I gave you. As it says in the description "Returns a synchronized (thread-safe) list".
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hello
Please check out the following picture:
http://i55.tinypic.com/35mk6eq.png[^]
I am interested in knowing what the left and right arrows mean precisely.
Does the arrow to the right mean that 'Thread' is dependent on 'Runnable'?
What does the left (bottom) arrow mean?
Someone told me it means 'inherits'.
I'm not sure how that relates to 'implements'.
It's all a bit fuzzy to me still.
Thank you for reading.
Regards,
|
|
|
|