- 浏览: 356844 次
- 性别:
- 来自: 南京
博客专栏
-
设计模式那些事儿
浏览量:5991
最新评论
-
Nabulio:
是不错的
Java的Integer与int互转 -
shihengli2010:
学习了 !Integer i = 100; Integer ...
Java的Integer与int互转 -
flex涵:
还可以,差不多就是这个意思.
Java的Integer与int互转 -
lijingshou:
相当好用。。。
输入年月日格式yyyyMMdd,判断是否是周末 -
denverj:
你好,是这本书的英文版,名字叫<Inside the J ...
JVM学习笔记-帧数据区(Frame Data)
文章列表
策略这两个字乍一听上去有点像三国志游戏里,那些鬼点子特别多的谋士出的阴谋阳谋之类的。但在面向对象的软件世界中,策略的范围要比谋略广很多。
我想以一款网络游戏来描述这个模式,玩过魔兽世界的人都知道它是比较早引入地下城(Dungeon)概念的游戏之一。地下城里有各种妖魔鬼怪给玩家砍啊杀啊。杀死boss后会掉落玩家所需要的各种装备。地下城从低级到高级,种类繁多,适合不同等级的玩家去探险刷装备。其中一些特殊的地下城因为难度较高,对玩家的人数有要求,需要组队才能通过冒险。越高难度需要的人数越多,当然奖励也会越丰厚。
如果你是一个足球迷,又喜欢玩一把游戏。那么你一定不会错过实况足球这款经典,无论是70,80,90,甚至00后,实况永远是我们青春的回忆。今年是实况足球发布第二十年,特别选了足球这个题材来讲解我想讲的这个特殊的模式。先贴图致敬经典吧。
足球是一项团队运动,一个队有11个人在比赛,这11个人各司其职。想要描述真实的足球比赛是异常复杂的,队员的能力,临场状态,阵型的安排,战术的布置,气候的影响都有可能影响比赛结果。
让我们把问题简单化,从队员职责的角度来分析足球。在实况足球里,一个队会有一个GK(守门员),至少一个CB(中卫),至少一个MF(中场),至 ...
相信不少人小时候都喜欢倒腾机器人或者四驱车之类的玩具。在我们这一辈的儿时,所有对此类玩具的印象来自于电视机。其实代表机器人的名作有很多,最出名的的是变形金刚这部经典。其实除了变形金刚还有一句台词相信能唤起我们儿时的回忆,那就是:我来组成头部!
没错,如果你跟我生活在相同的年代,你就会认出这是战神金刚第一部的台词!下面这副图是否能唤起你的回忆:)
今天要讲的主题就和上面的图片息息相关。我想先来介绍一下战神金刚的构造。^^在正常状态下,战神金刚是拆分成了15个不同的小机器人存在的。这15个小机器人有可以在天空飞行的飞机机器人,也有在水路航行的轮船机 ...
有学过物理课的同学都知道物理课本里面有固态,液态,气态,用来描述物体的形态。但在面向对象的软件世界中,状态可以用来描述各种各样的对象。比如你想在淘宝买一个商品,此时商品肯定是在售状态,如果这个商品已经售完;如果这个商品已经被买家购买一空,那么商品变成了售空状态;如果中途这个商品被发现质量有问题,于是变成了下架状态。当然真正的商品状态肯定不止这些,这里只是举了些例。
网络上有把状态模式说成是策略模式的孪生兄弟。从实现角度来讲他们确实非常类似。但它们的应用场景却略有不同。
我想接着上一节策略模式的例子,继续用魔兽世界这款游戏来讲解状态模式和策略模式的区别。
...
Solr
版本为3.6.1,在查询时加入以下条件
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.addFilterQuery("content:搜索内容");
query.setHighlight(true); //开启高亮组件
query.addHighlightField("content");//高亮字段
query.setHighlightSimplePre("<font color=\"r ...
If you have ever been discouraged because of failure, please read on.
如果你曾因失败沮丧过,请继续读下去。
For often, achieving what you set out to do is not the important thing. Let me explain.
完成你经常开始要做的事可不是大事,让我娓娓道来。
Two brothers decided to dig a deep hole behind their house. As they were ...
Invoking a Native Method
As mentioned in Chapter 5, "The Java Virtual Machine," the virtual machine
invokes native methods in an implementation dependent manner. When invoking a
native method, the virtual machine does not push a new stack frame onto the Java
stack for the nat ...
Invoking a Java Method
As mentioned in Chapter 5, "The Java Virtual Machine," the virtual machine
creates a new stack frame for each Java (not native) method it invokes. The
stack frame contains space for the method's local variables, its operand stack,
and any other information r ...
Generational Collectors
One disadvantage of simple stop and copy collectors is that all live
objects must be copied at every collection. This facet of copying algorithms can
be improved upon by taking into account two facts that have been empirically
observed in most programs in a varie ...
Copying Collectors
Copying garbage collectors move all live objects to a new area. As the
objects are moved to the new area, they are placed side by side, thus
eliminating any free space that may have separated them in the old area. The old
area is then known to be all free space. The a ...
Compacting Collectors
Garbage collectors of Java Virtual Machines will likely have a strategy to
combat heap fragmentation. Two strategies commonly used by mark and sweep
collectors are compacting and copying. Both of these approaches move objects on
the fly to reduce heap fragmentation ...
Tracing Collectors
Tracing garbage collectors trace out the graph of object references starting
with the root nodes. Objects that are encountered during the trace are marked in
some way. Marking is generally done by either setting flags in the objects
themselves or by setting flags in a ...
Reference Counting Collectors
Reference counting was an early garbage collection strategy. In this
approach, a reference count is maintained for each object on the heap. When an
object is first created and a reference to it is assigned to a variable, the
objectís reference count is set ...
最近项目当中正好使用到了applet,这个很少接触过的东东。
大体是在页面当中使用一个applet生成一个文本文件。
奇怪的是页面一直报错。
java.lang.ClassNotFoundException: framework.applet.FileUtil.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClas ...
When you compile a Java program, you get a separate class file for each class
or interface in your program. Although the individual class files may appear to
be independent, they actually harbor symbolic connections to one another and to
the class files of the Java API. When you run your pr ...