avatar
请教如何学习Java# Java - 爪哇娇娃
b*n
1
之前国务院已经公告,在今年的9月3日举行抗战胜利大阅兵。那么这次阅兵的意义和目
的又是什么样的,说明了什么问题呢?
这次的阅兵,不是传统意义上的阅兵,是为了庆祝抗战胜利周年纪念,而另外也透
露出和彰显了中国这东方大国的综合实力。当前的世界环境还算不上太平,而我们国家
却能在这么一个环境中稳定的搞好经济发展和科学进步是不容易的,是跟国家的军事力
量和军事保障分不开的。
现在的世界环境不太平,发生大规模战争的可能性虽不大,但是还是有一些势力一
直在蠢蠢欲动,伺机等待制造祸乱的机会。而国家这个时候的阅兵式,恰恰能够证明和
搏击这些恶势力,因为当今的中国已经是一个综合国力足够强大到任何一个国家都不可
小觑的过度,而且我们是一个追求世界团结和热爱和平的民族。
阅兵或许展现的不单是军事能力,也能反应出国家的经济能力,尤其是科技能力,
当今的中华民族是一个团结的民族,一个勇于创新和拼搏的民族,我们拥有和军事相媲
美的科学技术力量和技术人才,有一个民族的梦想——中国梦。
当今的中国,是一个社会主义事业蓬勃发展的中国,我们的民族和人民都在经济和
技术上同世界先进而争夺,如果说阅兵是一种硬的力量,那么展现的中华儿女的奋进就
是一种软实力。相信,通过这次抗战纪念阅兵,振奋的不仅是世界敌友,更多的是振奋
起中华民族的拼搏热情,因为我们的民族是中华民族。
avatar
n*e
2
请问一下, 平时用C++编程,现在因工作需要,要开始用Java编程,在有C++的基础下
,如何快速的学习Java?
不知道有什么open source 的project可以练习一下,顺便看看比较好的开源的Java
source codes是如何写的。
多谢!
avatar
Y*G
3
java 不就是简化版的c++吗,难的都会...

【在 n****e 的大作中提到】
: 请问一下, 平时用C++编程,现在因工作需要,要开始用Java编程,在有C++的基础下
: ,如何快速的学习Java?
: 不知道有什么open source 的project可以练习一下,顺便看看比较好的开源的Java
: source codes是如何写的。
: 多谢!

avatar
l*s
4
java's type erasure is very confusing. The shear number of design
patterns/frameworks is also daunting.

【在 Y**G 的大作中提到】
: java 不就是简化版的c++吗,难的都会...
avatar
c*e
5
java的东西都很简单的,但是很多术语都很唬人,什么di,就是通过setter来inject.
jsp是最简单的东西,做过一次就知道怎么回事了。

【在 l*********s 的大作中提到】
: java's type erasure is very confusing. The shear number of design
: patterns/frameworks is also daunting.

avatar
l*s
6
yes, overall Java is much more friendly. but there is some aspect like type
erasure/generic very difficult to get used to for C++ programmers.

【在 c*********e 的大作中提到】
: java的东西都很简单的,但是很多术语都很唬人,什么di,就是通过setter来inject.
: jsp是最简单的东西,做过一次就知道怎么回事了。

avatar
w*z
7
generic 是不是和c++里的template 差不多?不懂c++,好像在哪看来的。

type

【在 l*********s 的大作中提到】
: yes, overall Java is much more friendly. but there is some aspect like type
: erasure/generic very difficult to get used to for C++ programmers.

avatar
l*s
8
it looks similar, but type erasure is just terrible.

【在 w**z 的大作中提到】
: generic 是不是和c++里的template 差不多?不懂c++,好像在哪看来的。
:
: type

avatar
z*3
9
这个在实际运行时候是不存在的
只是在开发和编译的时候带给你一定的好处

【在 l*********s 的大作中提到】
: it looks similar, but type erasure is just terrible.
avatar
l*s
10
en, any open source java projects recommended for learning? especially in
terms of design patterns?

【在 z*******3 的大作中提到】
: 这个在实际运行时候是不存在的
: 只是在开发和编译的时候带给你一定的好处

avatar
t*a
11
c++的template是编译期或者前面什么期就被替换了,所以vector和vector>是两个完全不同的class
java语法差不多,但始终是一个class

【在 w**z 的大作中提到】
: generic 是不是和c++里的template 差不多?不懂c++,好像在哪看来的。
:
: type

avatar
z*3
12
会用就行了,当然你想contribute是很好的
一般情况下,不遇bug不碰源码

【在 l*********s 的大作中提到】
: en, any open source java projects recommended for learning? especially in
: terms of design patterns?

avatar
w*z
13
Java generic 后加的,还要backward compatible, 就成现在这样子了。

全不同的class

【在 t***a 的大作中提到】
: c++的template是编译期或者前面什么期就被替换了,所以vector和vector: >是两个完全不同的class
: java语法差不多,但始终是一个class

avatar
l*s
14
Just for self-teaching, :-)

【在 z*******3 的大作中提到】
: 会用就行了,当然你想contribute是很好的
: 一般情况下,不遇bug不碰源码

avatar
n*e
15
多谢大家的讨论,我也想看看比较好的open source java projects 的design
patterns。
avatar
r*r
16
Strategy Pattern一例,清晰易懂。如果非 OO 设计,就是弄三个 function 了。不过
,代码行数大大增加。
interface Strategy {
int execute(int a, int b);
}
/** Implements the algorithm using the strategy interface */
class Add implements Strategy {
public int execute(int a, int b) {
System.out.println("Called Add's execute()");
return a + b; // Do an addition with a and b
}
}
class Subtract implements Strategy {
public int execute(int a, int b) {
System.out.println("Called Subtract's execute()");
return a - b; // Do a subtraction with a and b
}
}
class Multiply implements Strategy {
public int execute(int a, int b) {
System.out.println("Called Multiply's execute()");
return a * b; // Do a multiplication with a and b
}
}
/** Configured with a ConcreteStrategy object and maintains a reference to a
Strategy object */
class Context {
private Strategy strategy;
public Context(Strategy strategy) {
this.strategy = strategy;
}
public int executeStrategy(int a, int b) {
return strategy.execute(a, b);
}
}
/** Tests the pattern */
class StrategyExample {
public static void main(String[] args) {
Context context;
// Three contexts following different strategies
context = new Context(new Add());
int resultA = context.executeStrategy(3,4);
context = new Context(new Subtract());
int resultB = context.executeStrategy(3,4);
context = new Context(new Multiply());
int resultC = context.executeStrategy(3,4);
System.out.println("Result A : " + resultA );
System.out.println("Result B : " + resultB );
System.out.println("Result C : " + resultC );
}
}

【在 l*********s 的大作中提到】
: en, any open source java projects recommended for learning? especially in
: terms of design patterns?

avatar
l*s
17
many thanks!

【在 r******r 的大作中提到】
: Strategy Pattern一例,清晰易懂。如果非 OO 设计,就是弄三个 function 了。不过
: ,代码行数大大增加。
: interface Strategy {
: int execute(int a, int b);
: }
: /** Implements the algorithm using the strategy interface */
: class Add implements Strategy {
: public int execute(int a, int b) {
: System.out.println("Called Add's execute()");
: return a + b; // Do an addition with a and b

avatar
p*2
18

Java可以弄三个function吗?

【在 r******r 的大作中提到】
: Strategy Pattern一例,清晰易懂。如果非 OO 设计,就是弄三个 function 了。不过
: ,代码行数大大增加。
: interface Strategy {
: int execute(int a, int b);
: }
: /** Implements the algorithm using the strategy interface */
: class Add implements Strategy {
: public int execute(int a, int b) {
: System.out.println("Called Add's execute()");
: return a + b; // Do an addition with a and b

avatar
n*e
19
谢谢你的strategy pattern啊。 和C++中的virtual functions 有点像
还有什么其他的design patterns吗?

【在 r******r 的大作中提到】
: Strategy Pattern一例,清晰易懂。如果非 OO 设计,就是弄三个 function 了。不过
: ,代码行数大大增加。
: interface Strategy {
: int execute(int a, int b);
: }
: /** Implements the algorithm using the strategy interface */
: class Add implements Strategy {
: public int execute(int a, int b) {
: System.out.println("Called Add's execute()");
: return a + b; // Do an addition with a and b

avatar
n*e
20
还有,不太理解你说的“如果非 OO 设计,就是弄三个 function 了”。
哪三个functions啊? 能展开说说吗?

【在 r******r 的大作中提到】
: Strategy Pattern一例,清晰易懂。如果非 OO 设计,就是弄三个 function 了。不过
: ,代码行数大大增加。
: interface Strategy {
: int execute(int a, int b);
: }
: /** Implements the algorithm using the strategy interface */
: class Add implements Strategy {
: public int execute(int a, int b) {
: System.out.println("Called Add's execute()");
: return a + b; // Do an addition with a and b

avatar
n*e
21
二爷对学习java有什么建议吗?

【在 p*****2 的大作中提到】
:
: Java可以弄三个function吗?

avatar
p*2
22

其实java不难学,core java的话看看书就差不多了,语法比较死板,变动不大。
看论坛绝大部分人都是搞j2ee的,这东西我没怎么好好学,感觉不难学,但是很看经验
。不做项目纯学可能够呛。很多概念不做大项目可能理解不好。

【在 n****e 的大作中提到】
: 二爷对学习java有什么建议吗?
avatar
r*r
23
用 C++ 的时候,觉得 c++ 很好。看了 template 用得熟的高手的代码,觉得很 cool.
原来 template 能够用得这么广泛。
现在都不弄 c++ 了。作为练习,最近刚刚把自己原来写过一段 code 改成 Strategy
了。三个 load() method, 根据不同文件格式,每个 load() 有所不同。改成
Strategy 试了试,感觉那段代码就好像就高了一个档次。
发现对象,封装做得好的设计,就是不一样,感觉代码就像贵族一样。

【在 n****e 的大作中提到】
: 谢谢你的strategy pattern啊。 和C++中的virtual functions 有点像
: 还有什么其他的design patterns吗?

avatar
r*r
24
哦,我就是说这样的;
public static int add (int a, int b){}
public static int subtract(int a, int b){}
public static int multiply(int a, int b){}
public static int divide(int a, int b){}

【在 n****e 的大作中提到】
: 还有,不太理解你说的“如果非 OO 设计,就是弄三个 function 了”。
: 哪三个functions啊? 能展开说说吗?

avatar
n*e
25
哈哈,这样啊

cool.

【在 r******r 的大作中提到】
: 用 C++ 的时候,觉得 c++ 很好。看了 template 用得熟的高手的代码,觉得很 cool.
: 原来 template 能够用得这么广泛。
: 现在都不弄 c++ 了。作为练习,最近刚刚把自己原来写过一段 code 改成 Strategy
: 了。三个 load() method, 根据不同文件格式,每个 load() 有所不同。改成
: Strategy 试了试,感觉那段代码就好像就高了一个档次。
: 发现对象,封装做得好的设计,就是不一样,感觉代码就像贵族一样。

avatar
n*e
26
恩,明白了。

【在 r******r 的大作中提到】
: 哦,我就是说这样的;
: public static int add (int a, int b){}
: public static int subtract(int a, int b){}
: public static int multiply(int a, int b){}
: public static int divide(int a, int b){}

avatar
n*e
27
恩,谢谢二爷指点。我估计也是要用j2ee的。 现在学java都是看oracle的online
tutorial之类的。

【在 p*****2 的大作中提到】
:
: 其实java不难学,core java的话看看书就差不多了,语法比较死板,变动不大。
: 看论坛绝大部分人都是搞j2ee的,这东西我没怎么好好学,感觉不难学,但是很看经验
: 。不做项目纯学可能够呛。很多概念不做大项目可能理解不好。

avatar
p*2
28

没明白你这是什么意思。

【在 r******r 的大作中提到】
: 哦,我就是说这样的;
: public static int add (int a, int b){}
: public static int subtract(int a, int b){}
: public static int multiply(int a, int b){}
: public static int divide(int a, int b){}

avatar
n*e
29
就是不用面向对象的思想吧,用单个的function来处理吧

【在 p*****2 的大作中提到】
:
: 没明白你这是什么意思。

avatar
p*2
30

跟strategy有啥关系呢?

【在 n****e 的大作中提到】
: 就是不用面向对象的思想吧,用单个的function来处理吧
avatar
n*e
31
单个function跟strategy没关系。
那个OO design的codes是遵循的strategy pattern。

【在 p*****2 的大作中提到】
:
: 跟strategy有啥关系呢?

avatar
p*2
32

Strategy Pattern一例,清晰易懂。如果非 OO 设计,就是弄三个 function 了。
这句话怎么理解?OO设计给了例子。怎么弄三个function?

【在 n****e 的大作中提到】
: 单个function跟strategy没关系。
: 那个OO design的codes是遵循的strategy pattern。

avatar
n*e
33
他的意思是说:如果用strategy pattern, codes就是这个样子的:
=====================================================
interface Strategy {
int execute(int a, int b);
}
/** Implements the algorithm using the strategy interface */
class Add implements Strategy {
public int execute(int a, int b) {
System.out.println("Called Add's execute()");
return a + b; // Do an addition with a and b
}
}
class Subtract implements Strategy {
public int execute(int a, int b) {
System.out.println("Called Subtract's execute()");
return a - b; // Do a subtraction with a and b
}
}
class Multiply implements Strategy {
public int execute(int a, int b) {
System.out.println("Called Multiply's execute()");
return a * b; // Do a multiplication with a and b
}
}
/** Configured with a ConcreteStrategy object and maintains a reference to a
Strategy object */
class Context {
private Strategy strategy;
public Context(Strategy strategy) {
this.strategy = strategy;
}
public int executeStrategy(int a, int b) {
return strategy.execute(a, b);
}
}
=====================================================
如果不用strategy pattern,就简单的用单独的functions就可以了。codes是这个样子
的:
=====================================================
public static int add (int a, int b){}
public static int subtract(int a, int b){}
public static int multiply(int a, int b){}
public static int divide(int a, int b){}
======================================================
就是用两种不同的方式来实现 +, -, ×, /
我是这么理解的。

【在 p*****2 的大作中提到】
:
: Strategy Pattern一例,清晰易懂。如果非 OO 设计,就是弄三个 function 了。
: 这句话怎么理解?OO设计给了例子。怎么弄三个function?

avatar
p*2
34

多谢。这次看明白了。看来他对strategy理解有很大的问题呀。

【在 n****e 的大作中提到】
: 他的意思是说:如果用strategy pattern, codes就是这个样子的:
: =====================================================
: interface Strategy {
: int execute(int a, int b);
: }
: /** Implements the algorithm using the strategy interface */
: class Add implements Strategy {
: public int execute(int a, int b) {
: System.out.println("Called Add's execute()");
: return a + b; // Do an addition with a and b

avatar
n*e
35
二爷展开说说strategy应该是啥样的啊

【在 p*****2 的大作中提到】
:
: 多谢。这次看明白了。看来他对strategy理解有很大的问题呀。

avatar
p*2
36

你随便wiki一下就可以了。strategy长的确实是那个样子的,但是实际不是那个东西。
我以前没仔细看,我说怎么一直没明白呢。

【在 n****e 的大作中提到】
: 二爷展开说说strategy应该是啥样的啊
avatar
n*e
37
我就是看了wiki,觉得那个人写的挺像的。
为啥二爷说“实际不是那个东西”

【在 p*****2 的大作中提到】
:
: 你随便wiki一下就可以了。strategy长的确实是那个样子的,但是实际不是那个东西。
: 我以前没仔细看,我说怎么一直没明白呢。

avatar
p*2
38

In computer programming, the strategy pattern (also known as the policy
pattern) is a software design pattern, whereby an algorithm's behaviour can
be selected at runtime. Formally speaking, the strategy pattern defines a
family of algorithms, encapsulates each one, and makes them interchangeable.

【在 n****e 的大作中提到】
: 我就是看了wiki,觉得那个人写的挺像的。
: 为啥二爷说“实际不是那个东西”

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。