由买买提看人间百态

topics

全部话题 - 话题: objected
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
r*****s
发帖数: 985
1
来自主题: Java版 - how to copy an Object?
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.
c*****t
发帖数: 1879
2
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...
g*****g
发帖数: 34805
3
比如下面的代码,firefox可以,IE不行,估计又是IE不遵守W3C
width="600" height="480">
http://qaws:8800/bosgames">

http://qaws:8800/game_servlet">


B*********h
发帖数: 800
4
来自主题: Java版 - Object比较
o1 == o2 : only when o1 and o2 are the same object.
o1.equals(o2): implemented as {return o2 ==null ? false : o1 == o2;}by defau
lt in Object class.
B*********h
发帖数: 800
5
来自主题: Java版 - Object比较
how are e and f THE same object?
e = new Officer(...);
f = new Officer(...);
different objects.
g*****g
发帖数: 34805
6
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?
s******e
发帖数: 493
7
来自主题: Java版 - what's inside an java object?

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
L*********r
发帖数: 92
8
来自主题: Java版 - what's inside an java object?
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.
machine
This
m******t
发帖数: 2416
9
来自主题: Java版 - what's inside an java object?

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++.
c*****t
发帖数: 1879
10
Hehe, this size would be quite different from the actual object
size. Since it would include String and other referened objects.
LZ needs to clarify.
P*P
发帖数: 36
11
来自主题: Java版 - return type, map or object
在写一个class,要return三个参数,我现在是把三个参数放到map里,然后return map.不
知道这样做好不好?还是我应该把三个参数做成object,然后return那个object?
s******e
发帖数: 493
12
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)
k***r
发帖数: 4260
13
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
c**o
发帖数: 186
14
不好意思,
事多,给忘了这茬.
我当时的意思是parameters.
如果parameters是object.
这个object有可能会被这个method修改.
所以有此疑问.
如果这个method是sychronized, 它的parameters是不是也默认为synchronized.
谢谢大家
m***i
发帖数: 213
15
标题没法描述清楚。问题是这样的:
本来是jsp的form submit到servlet,target是一个iframe,这样servlet可以forward
到另一个jsp,显示会用iframe嵌入。现在不用iframe,改用来实现嵌入,这样
就不能用target了,servlet应该怎么做,才能返回object替代iframe和target的功能
呢?
S**********C
发帖数: 161
16
来自主题: Java版 - 问个Object.hashCode()的问题
书上说,一般Override equals()的时候要同时Override hashCode()
那么,如果我
1)不Override hashCode()
2)Override hashCode(),但返回一个常数,比如10
3)Override hashCode(),但随机产生一个数,而不是根据
一般的根据Object里面的Fields(e.g Employee(employeeId,name)来定
以上三种情况,后果分别是什么?Java是如何判断两个
Object是否"相等",只要equals() return true,还是同时要
hashCode()返回相同的值?
S**********C
发帖数: 161
17
来自主题: Java版 - 问个Object.hashCode()的问题
我知道这个是个Convention,最好要Follow,这么说吧,这
是一个面试的时候别人问到的题目,我答得跟你们说的都差不多,
但好像面试的人仍然要追问,如果不这么做,会发生什么,
我回头看了你回答的第1)个,如果不Override,不应该就用
Object defatult的hashCode() 吗?
我查了一下源代码,equals() default implementation是 return this == obj,
也就是比较两个obj在内存里面是否指向同一个reference,但
hashCode() default implementation是一个native function,不知道
里面是怎么实现的,default会返回什么数值,是否也是
一个常数,那就变成问题2)? 还有对于会造成mess up,面试
的会追问怎么个mess up法,是容许duplicate了呢,还是put了
之后想get的时候返回不同值?那如果不放在HashMap里呢,比如
一个Seariable的Object,是否有同样的问题?
我觉得搞清楚这点还是有点意义的,决不是"Just a con... 阅读全帖
x*****p
发帖数: 1707
18
来自主题: Java版 - 问个Object.hashCode()的问题
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)
b***e
发帖数: 15201
19
我刚开始学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... 阅读全帖
l*******w
发帖数: 61
20
言之有理。多谢了。
看来实在需要的话,只好多加一个attribute....
public class GenericReflection
{
private T object;
private Class objectClass; //cntr passed in
...
}//end class GenericReflection
这样勉强可保证object是null时,也可知其可能的Class。
谢谢
l*******w
发帖数: 61
21
言之有理。多谢了。
看来实在需要的话,只好多加一个attribute....
public class GenericReflection
{
private T object;
private Class objectClass; //cntr passed in
...
}//end class GenericReflection
这样勉强可保证object是null时,也可知其可能的Class。
谢谢
f*******n
发帖数: 12623
22
来自主题: Java版 - Java Object 一定在 Heap 里吗
And what the hell is a "class object"?

object.
stack
b******y
发帖数: 9224
23

,想
有的情况下可能有用。我感觉主要就是方便。 比如说, java直接serialize object成
为byte array, 然后可以用base64 encoding将byte array变成String. 这样的话,就
可以将信息传走了。
如果用另外一种语言来将object转换成可以交换的格式,貌似没有必要。除非是接收方
是其他的编程语言。
a*s
发帖数: 425
24
仍然在学习Java中,
关于Java load class的问题
我知道,java可以动态的load外部jar,然后用这个jar的method 初始化instance,
我想知道哦,比如,我有一个runable jar,假设,如果直接运行这个jar,会初始化大
量的object instances
我是否用另外一个java code load 这个jar,然后运行这个runable jar的原本的main,
然后直接access这个runable jar初始化的大量instances,我不需要改动任何东西,只
需要collect一些信息,换句话说,如果,我不可以改动这个runable jar,我想实时
monitor这个程序runtime 初始化的object instances 的状态,这个能否做到?
谢谢
e********2
发帖数: 495
25
Hibernate:
List cats = session.createSQLQuery("select * from t1, t2").addEntity("
cat.class").list();

cats中每个object和session有联系吗?如果cat中有food object,Lazy fetching能用
吗?

如果第一个*是由t1,t2中的几个field组成的,是不是cat必须有相应的constructor
y****i
发帖数: 156
26
来自主题: Programming版 - How to initialize object in constructor?

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
i**p
发帖数: 902
27
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
i**p
发帖数: 902
28
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?
b***y
发帖数: 2799
29
来自主题: Programming版 - [合集] C++ question -- how to save objects
☆─────────────────────────────────────☆
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
b***y
发帖数: 2799
30
☆─────────────────────────────────────☆
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
b*********n
发帖数: 1258
31
【 以下文字转载自 Java 讨论区 】
发信人: babyfacenan (黑土), 信区: Java
标 题: 请问: 有什么tool可以查java里每个object用了多少memory?
发信站: BBS 未名空间站 (Wed Jul 15 22:29:29 2009, 美东)
试了:java -Xrunhprof
可是还是看不到具体是哪一个object
请问有什么更好用的tool吗?
另外,请问用了这个option之后
dumped的java.hprof.txt 文件里的stack trace 是指什么呀?
谢谢
mw
发帖数: 525
32
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!
z****e
发帖数: 2024
33
再问一个问题,并祝大侠周末愉快,
我在自定义的那个function object里边加了一个cout和一个static int cnt的计数器。
发现这个function object被调用的次数,是我那个p->size()的两倍。这是为什么呢?
还是我又搞错了?
c*****s
发帖数: 49
34
来自主题: Programming版 - 请教显示object name的问题(c++)
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.
v****s
发帖数: 1112
35
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? 具体给讲讲?
G****A
发帖数: 4160
36
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."
我怎么觉得不对呢,还是我理解错了?
e********t
发帖数: 144
37
来自主题: Programming版 - 学objective-c难吗?
objective-c 和Cocoa这个framework是集成在一起的。
算是聪明人喜欢的语言和框架。以前用户集中在大学和华尔街。我觉得java 很大程度
模仿了它。
推荐两本书:
Learn objective-c for java developer.
cocoa programming (这书厚达1200多页)
在Appstore上发表个作品就是你的投名状啦。
d******3
发帖数: 70
38
从来没学过Objective C, 很curious这个语言到底怎么样。如果给你Objective C和C++
选一个,选哪个?
n*w
发帖数: 3393
39
object c从濒死到可能是代码量最大语言之一确实让人吃惊。object c是c的一个严格
superset。c++不是。
d******3
发帖数: 70
40
从来没学过Objective C, 很curious这个语言到底怎么样。如果给你Objective C和C++
选一个,选哪个?
n*w
发帖数: 3393
41
object c从濒死到可能是代码量最大语言之一确实让人吃惊。object c是c的一个严格
superset。c++不是。
p*****2
发帖数: 21240
42
来自主题: Programming版 - OOP里面的Object其实是actor
Scala里面的actor也是object吧?也是OOP的东西。Erlang不熟悉,不过感觉actor本来
也是个object,封装性很强。但是不share state,性能有影响。
N******K
发帖数: 10202
43
来自主题: Programming版 - OOP里面的Object其实是actor
编程序 和 系统仿真 完全不一样
所谓的object 可以对应物理世界的一个实物 有状态 有动作 比如打印机
thread和object不一样
比如一台打印机 安装多个打印鼓 相当于多线程
在量子计算机出来之前 搞和物理世界一对一的仿真 是不可能的

Erlang
g*****g
发帖数: 34805
44
来自主题: Programming版 - OOP里面的Object其实是actor
你走火入魔了,谁说对象需要独立人格?这个世界万物皆物体 (object),物体需要独
立人格吗?
一个桌子没有任何思想,就不能有4条腿,一个面吗?你连最基本的常识都弄错了,还
推理了一大堆,I服了U。
事实上,OO里所谓对象,无非是一堆的相关的数据状态,用对象方法来确保数据的变化
保持一致性罢了。
另外,你对多线程的理解也很狭隘。actor model在复杂多线程的系统里很好用,可以
简化线程同步。
但反过来,如果系统并没有那么多的同步需要。比如绝大部分web应用,无非是某种形
式的CRUD,
有同步需要的部分都在数据库里处理了。这时候actor就如同spring bean里用
prototype,明明一个singleton够用了,却产生了大量的copy,导致GC开销提高很
多,造成性能下降。我个人用scala的时候为了最大化系统throughput,在调GC仍然有
问题之后,不得已用了object pool来重用actor,这已经违背了actor model的本意。

Erlang
s****y
发帖数: 503
45
看了一下Swift,感觉对于有Java/JavaScript基础的人比较容易,如果我没有多少
Objective-C的基础,是不是应该直接学Swift,不要学Objective-C了?
K*********n
发帖数: 2852
46
Scala纯新手,写了点测试代码:
###### build.sbt #########
name := "Train NB"
version := "1.0"
scalaVersion := "2.10.4"
libraryDependencies ++= Seq(
"org.apache.spark" %% "spark-core" % "1.2.0",
"commons-io" % "commons-io" % "2.4",
"com.google.code.gson" % "gson" % "2.2.4",
"org.la4j" % "la4j" % "0.4.9"
)
javacOptions ++= Seq("-source", "1.7", "-target", "1.7")
####### scala code ##########
package app.mycompany
import org.apache.spark.SparkContext
import org.apache.spark.SparkContext._
import org.apa... 阅读全帖
L********t
发帖数: 3
47
来自主题: Programming版 - OOP胜出是因为object而不是class
在早期,程序基本都是从头跑到尾的一根筋的类型,主要用来解决计算问题,基本上是
为了实现算法的。
在近代,大量的商业应用,让算法成为了局部的需求,总体的需求是计算机和软件本身
成为商业运作中的一个成员,比如作为银行账本,库存清单,学校花名册等等。
在现代,也就是互联网时代,计算机和软件本身成为了商业的主角,甚至开创了新型的
商业模式,比如Ebay, Netflix, Facebook, Airbnb, Uber等等。
早期的应用,procedural functions and functional functions 可以应付得很好。近
代的应用,规模大增,这两种function在数量上满足不了应用的规模。只有object这个
技术,可以在design time写一次代码,然后在runtime生成大量的object。
但OOP在现代,没有跟上应用的需要,甚至没有跟上硬件和网络技术的发展。硬件贡献
了多核CPU技术,网络贡献了互联网技术。
现在的局面是,通用编程技术没有跟上互联网应用的节奏。科学和工业界都没有提出有
效的编程技术和语言(都是局限在单个计算机内的)。在现实中,只能用web ... 阅读全帖
W***o
发帖数: 6519
48
来自主题: Programming版 - OOP胜出是因为object而不是class
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?
c*********e
发帖数: 16335
49
swift就是objective-c上加了一层皮,编译的时候,swift先编译成objective-c,再继
续。这个swift也太搞了。
s*********y
发帖数: 6151
50
是。 确实是通用做法。
听说过用快速zip放redis对于大的object 可以省点内存
你可以再在redis里建个查找表如果需要序列的话。
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)