用Java创建对象 [英] create objects in java

查看:72
本文介绍了用Java创建对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以通过多种方式在java ..中创建对象.
请解释.....

In how many ways we can create objects in java..?
plz explain .....

推荐答案

有多少种方法?

有一种方法:
How many ways?

There is one way:
Object object = new Object();



否则,该对象需要由另一部分给定.
可以将对象/对象副本作为参数移交:



Otherwise the Object needs to be given by another part.
One can hand over Objects/Copies of Objects as arguments:

public void method(Object object){
  // doany();
}


但是后来对象就在ohter方法中了.

有时在创建对象的位置以及出现原因/方式方面不直接可见.
使用框架时经常会发生这种情况.春天例如具有通过XML定义创建"对象的机制.

编辑:您阅读过吗? 创建对象-Java教程 [


But then the Object has been there in the ohter method.

It''s sometimes not directly visible where an Object is created and why/how it is coming up.
That''s often happening when using a framework. Spring e.g. has a mechanism to "create" Objects by a XML definition.

EDIT: have you read this? Creating Objects - The Java Tutorial[^] @ oracle.com


这篇关于用Java创建对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆