first, it depends on what "copy" means here. does your "copy" here mean
creating another object without calling its constructor?
generally, if you don't like the generic Object.clone(), why not
override it? You can provide your own way of "copy" in this way.
ffdt.
Read the sample again. It first converts a string into bytes, then
put these bytes into datagram packet and then send it out.
What you can do to send objects is to first serialize the objects
into bytes, then put the bytes into datagram...
for hibernate?
if i check a.equals(b) in a hibernate session, if they have the same id,
the equation should always be true, right? Because the same object will not
be loaded twice in hibernate.
So I don't need to write equals and hashcode for domain object,
am I correct?
the
the
answer.
machine
This
Basically you can think that java uses the same four areas as c++ does. heap
, code, data, and stack. As I know, the method code are shared. But how to
organize the memory is kind of depending on the jvm vendor in java. Usually
this is not important if you are not writing jvm or doing some fancy thing
such as dynamic replacement of an active class.
java uses metadata object to store the refelction data of a class. The
metadata object itself is also a subclass of obj
Generally, the memory layout of Java object has the header and body.
The header has a reference to the class which defines the method.
The body is almost same as a non-vf/vb C++ object as what you already know.
the
the
answer.
I for one don't know and don't care about the run-time memory layout of Java
objects - because I can't pretty much do anything about it even if I did.
Besides, different JVMs may choose to implement it differently.
machine
This
Remote "references" are implemented completely differently from the object
references within the same JVM.
Each JVM may choose to implement late binding differently, but I think most
of the implementations are based on virtual tables, just like in C++.
in java, each object or class instace has one single monitor(lock).
synchronized keyword is the way to grab that lock. The lock is exclusive to
the threads. depending on how you use it, the lock you try to get can be the
class instance lock(when using static keyword), object instance lock(
explicit or implicit)
My understanding is, when an object monitor is being used,
the access to that object is exclusive. So it is locked,
unless you have other methods that's not protected by this
synchronized()l
Suppose a and b are two objects, Java uses the following condition to
check whether a and b are duplicated objects.
a.hashCode()==b.hashCode() && a==b || a.equals(b)
我刚开始学gwt,想做个小应用,call一个web service(SOAP),该service会返回一个
object数组,然后我想用gwt的一些widgets在用户端来显示这个object数组包含的数据。
现在我是在gwt的server code里面调用web service,成功的取到了这个对象数组"
errorlist"。 我想把errorlist返回给client code。
我google来的近似答案是,需要把errorlist这个class放在shared目录,让client
side code可以编译到它。
但是现在的问题是,这个errorlist从WSDL生成,里面用到了org.apache.axis的一些类
。如果是把这个类文件放server端编译就毫无问题。放到shared目录后,就出错,说是:
org.apache.axis.description.ElementDesc can not be found in source packages.
Check the inheritance chain from your module; it may not be... 阅读全帖
言之有理。多谢了。
看来实在需要的话,只好多加一个attribute....
public class GenericReflection
{
private T object;
private Class extends T> objectClass; //cntr passed in
...
}//end class GenericReflection
这样勉强可保证object是null时,也可知其可能的Class。
谢谢
言之有理。多谢了。
看来实在需要的话,只好多加一个attribute....
public class GenericReflection
{
private T object;
private Class extends T> objectClass; //cntr passed in
...
}//end class GenericReflection
这样勉强可保证object是null时,也可知其可能的Class。
谢谢
I mean, I tried for both case in the constructor
PointColl::PointColl(int num,const Point& p):
number(num)
thePointer(p);
{
}
and get an error "cannot convert 'Point' to 'Point*' in initialization
//---------------------------------
thePointer is a pointer(Point*) , however p is an object(Point)
You cannot assign a object to a pointe. If you really want to, you have to
cast it like thePoint = (Point*) p; // dangerous
Are you clear?
but if i use
PointColl::PointColl(int num,const Point& p):numbe
How can I define a reference to ensure it will always reference the same
object but you can use the reference to modify the object's values?
The follow FAQ says a reference is always const. Do you agree it? http://www.parashift.com/c++-faq-lite/const-correctness.html
...
[18.7] Does "Fred& const x" make any sense?
No, it is nonsense.
To find out what the above declaration means, you have to read it right-to-
left. Thus "Fred& const x" means "x is a const reference to a Fred". But
that is redunda
Now let us back to my original question.
How can I define a reference to ensure it will always reference the same
object but you can use the reference to modify the object's values?
So according to our analysis, we don't need to do anything special but just
declare a simple reference like this,
base& ref_1 = b;
Am I right?
☆─────────────────────────────────────☆
system (系统管理员-困惑中...) 于 (Wed Aug 31 19:25:53 2005) 提到:
Is there any simple way or lib to save/restore C++ objects to/from persistant
storage? Like the java Object Serialization ...
Thanks.
☆─────────────────────────────────────☆
lzl (李作乐) 于 (Wed Aug 31 20:29:59 2005) 提到:
for MFC, it's simple.
don't know others
persistant
☆─────────────────────────────────────☆
system (系统管理员-困惑中...) 于 (Wed Aug 31 23:08:56 2005) 提到:
not MFC a. :(
C++ does
☆─────────────────────────────────────☆
noid (DoIneedit?) 于 (Tue Jun 3 01:24:54 2008) 提到:
the return value can be const or non-const. If the value is used as the
argument of fuction such as f(a+b), the result of a+b becomes a temporary
object. "Thinking in C++" says the temporary object is automatically const.
As a const, only the const member function can be used. However, my test
case works on non-const member function too. Here it is. What is wrong?
#include
using namespace s
hi, everyone
i have a python class like this
def classA:
def __init__(self):
#.....
test_list = list()
for i = range (1,10):
test_list.append(classA())
but in the end, all the 10 items in test_list seem point to the same
classA object
how can I have one classA object for each item in the list ?
does any guru got an idea!
thanks a lot!
Thank you for your answer. However, after reading some info online, it seems
RTTI deals with the type of the object only (esp. for hiearchies of
inherited classes). I could not figure out how to use it to infer the object
name. Please let me know if I'm missing something. Thanks.
From Java API doc:
finalize
protected void finalize()
throws Throwable
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object. A subclass
overrides the finalize method to dispose of system resources or to perform
other cleanup.
问题是,这个gc是以何种形式在runtime中出现的?为何这个finalize()要定义成
protected而不是
private? 具体给讲讲?
cited from C++ faq
"Unlike a pointer, once a reference is bound to an object, it can not be
reseated to another object.
....
In that sense, a reference is similar to a const pointer such as int*
const p."
我怎么觉得不对呢,还是我理解错了?
this is a chicken-and-egg question.
without class, how do you get object instantiated memory? without physical/
imaginary
object, how do you get class?