问题描述
我用Google搜索这一点,并阅读Java文档,但我是一个有点困惑。有人可以请解释一下什么是上下文
是用简单的英语?
I Googled this and read the Java documentation, but I'm a bit confused. Can somebody please explain what a Context
is in plain English?
推荐答案
在编程方面,这是更大的周围部分可具有的在当前工作单位的行为的任何的影响。例如。正在运行的环境中使用,环境变量,实例变量,局部变量,其他类的状态,当前的环境状况,等等。
In programming terms, it's the larger surrounding part which can have any influence on the behaviour of the current unit of work. E.g. the running environment used, the environment variables, instance variables, local variables, state of other classes, state of the current environment, etcetera.
在一些API的,你看这个名字早在一个接口/类,如servlet的<$c$c>ServletContext$c$c>, JSF的<$c$c>FacesContext$c$c>, Spring的<$c$c>ApplicationContext$c$c>, Android的 上下文
,JNDI的<$c$c>InitialContext$c$c>,等他们都经常跟随 外观模式 进行抽象的环境细节的最终用户不需要了解远在一个单一的接口/类。
In some API's you see this name back in an interface/class, e.g. Servlet's ServletContext
, JSF's FacesContext
, Spring's ApplicationContext
, Android's Context
, JNDI's InitialContext
, etc. They all often follow the Facade Pattern which abstracts the environmental details the enduser doesn't need to know about away in a single interface/class.
这篇关于究竟什么是Java中的语境?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!