首页编程java编程java 中- gt 是什么意思?JAVA 中的 -> 是什么意思

java 中- gt 是什么意思?JAVA 中的 -> 是什么意思

编程之家2023-10-1297次浏览

大家好,今天小编来为大家解答java 中- gt 是什么意思这个问题,JAVA 中的 -> 是什么意思很多人还不知道,现在让我们一起来看看吧!

java 中- gt 是什么意思?JAVA 中的 -> 是什么意思

JAVA 中的 -> 是什么意思

java中的多重继承是什么意思? java的多重继承指的是一个类可以继承另外一个类,而另外一个类又可以继承别的类,比如A类继承B类,而B类又可以继承C类,这就是java中的多重继承。需要注意的是,java中有多重继承的概念,但却没有多继承的概念,一个类有且仅有一个父类,这是java单继承的局限性。java中通过实现接口来达到多继承的功能目的。一个类只能继承一个类,但是却可以实现多个接口!

java这个什么意思,为什么最后是这个结果

执行结果是x:-5 y:-1

publicclassTest{

java 中- gt 是什么意思?JAVA 中的 -> 是什么意思

publicstaticvoidmain(String[]args){

intx=1;

inty=6;

java 中- gt 是什么意思?JAVA 中的 -> 是什么意思

/**y--是自减的意思,等效于:y=y-1

*特点:先运算后自减

*while()中boolean值为true的时候执行循环体;

*否则不执行,但是()里面的判断这个运算还是要执行的

*/

while(y-->0){

x--;

}

System.out.println("x:"+x+"y:"+y);

}

}

关键步骤解释:

最后一次执行完循环体的时候x:-5 y:0。

当y=0再次判断的时候boolean值为false,此时x--不执行,x=-5。

但是:判断这个运算本身还是执行了,只要执行完次条语句,x就会自减1,所以最后x=-1

Java中"->"符号是什么意思啊

annotation。

Annotation,是Java5的新特性,下面是Sun的Tutorial的描述,因为是英文,这里我翻译下,希望能够比较清晰的描述一下Annotation的语法以及思想。Annotation:Release 5.0 of the JDK introduced a metadata facility called annotations. Annotations provide data about a program that is not part of the program, such as naming the author of a piece of code or instructing the compiler to suppress specific errors. An annotation has no effect on how the code performs. Annotations use the form@annotation and may be applied to a program's declarations: its classes, fields, methods, and so on. The annotation appears first and often(by convention) on its own line, and may include optional arguments: JDK5引入了Metedata(元数据)很容易的就能够调用Annotations.Annotations提供一些本来不属于程序的数据,比如:一段代码的作者或者告诉编译器禁止一些特殊的错误。An annotation对代码的执行没有什么影响。Annotations使用@annotation的形势应用于代码:类(class),属性(field),方法(method)等等。一个Annotation出现在上面提到的开始位置,而且一般只有一行,也可以包含有任意的参数。@Author("MyName")class myClass(){}

or@SuppressWarnings("unchecked")void MyMethod(){}

Defining your own annotation is an advanced technique that won't be described here, but there are three built-in annotations that every Java programmer should know:@Deprecated,@Override, and@SuppressWarnings. The following example illustrates all three annotation types, applied to methods:

定义自己的Annotation是一个比较高级的技巧,这里我们不做讨论,这里我们仅仅讨论每一个Java programer都应该知道的内置的annotations:@Deprecated,@Override, and@SuppressWarnings。下面的程序阐述了这三种annotation如何应用于methods。import java.util.List;

class Food{}

class Hay extends Food{}

class Animal{

Food getPreferredFood(){

return null;}/***@deprecated document why the method was deprecated*/

@Deprecated

static void deprecatedMethod(){}

}

class Horse extends Animal{

Horse(){

return;

}

@Override

Hay getPreferredFood(){

return new Hay();

}

@SuppressWarnings("deprecation")

void useDeprecatedMethod(){

Animal.deprecateMethod();//deprecation warning- suppressed}}

}

}

@DeprecatedThe@Deprecated annotation indicates that the marked method should no longer be used. The compiler generates a warning whenever a program uses a deprecated method, class, or variable. When an element is deprecated, it should be documented using the corresponding@deprecated tag, as shown in the preceding example. Notice that the tag starts with a lowercase"d" and the annotation starts with an uppercase"D". In general, you should avoid using deprecated methods— consult the documentation to see what to use instead.

@Deprecated@Deprecated annotation标注一个method不再被使用。编译器在一个program(程序?)使用了不赞成的方法,类,变量的时候会产生警告(warning)。如果一个元素(element:method, class, or variable)不赞成被使用,应该像前面的例子里使用相应的@deprecated标签,并且注意标签的首字母是小写的"d",而annotation时大写的"D"。一般情况下,我们应该避免使用不赞成使用的方法(deprecated methods),而应该考虑替代的方法。

@OverrideThe@Override annotation informs the compiler that the element is meant to override an element declared in a superclass. In the preceding example, the override annotation is used to indicate that the getPreferredFood method in the Horse class overrides the same method in the Animal class. If a method marked with@Override fails to override a method in one of its superclasses, the compiler generates an error. While it's not required to use this annotation when overriding a method, it can be useful to call the fact out explicitly, especially when the method returns a subtype of the return type of the overridden method. This practice, called covariant return types, is used in the previous example: Animal.getPreferredFood returns a Food instance. Horse.getPreferredFood(Horse is a subclass of Animal) returns an instance of Hay(a subclass of Food). For more information, see Overriding and Hiding Methods.

@Override@Override annotation告诉编译器当前元素是重写(override)自父类的一个元素。在前面的例子中,override annotation用来说明Horse类中的getPreferredFood这个方法重写(override)自Animal类中相同的方法。如果一个方法被标注了@Override,但是其父类中没有这个方法时,编译器将会报错。但是并不是说我们一定要使用这个annotation,但是它能够很明显的给出实际行为,尤其是在方法返回一个被重写的方法返回类型的子类型的时候。上面的例子中,Animal.getPreferredFood返回一个 Food实例,Horse.getPreferredFood返回一个Hay实例,这里Horse是Animal的子类,Hay是Food的子类。

@SuppressWarningsThe@SuppressWarnings annotation tells the compiler to suppress specific warnings that it would otherwise generate. In the previous example, the useDeprecatedMethod calls a deprecated method of Animal. Normally, the compiler generates a warning but, in this case, it is suppressed. Every compiler warning belongs to a category. The Java Language Specification lists two categories:"deprecation" and"unchecked". The"unchecked" warning can occur when interfacing with legacy code written before the advent of generics. To suppress more than one category of warnings, use the following syntax:@SuppressWarnings@SuppressWarnings annotation告诉编译器禁止别的元素产生的特殊的警告(warnings),在前面的例子里,useDeprecatedMethod调用了Animal的不赞成使用的一个方法。一般情况下,编译器会给出一个警告(warning),但是在这种情况下,不会产生这个警告,也就是说被suppress。每个编译器的警告都属于一个类型。Java Language Specification列出了两种类型:"deprecation"和"unchecked"。"unchecked" warning发生在使用非generic的旧代码交互的generic collection类时。为了禁止不止一种的警告时,使用下面的语法:@SuppressWarnings({"unchecked","deprecation"})

JAVA 中<t>是什么意思,

JAVA中<t>是泛型的意思。

意思是Tree这个类里面需要用到另外一个类,但是又不能确定要用到的那个类的具体类型,所以暂时用T来代替。

当具体的程序知道要用到的那个类型是什么的时候就用那个类型来代替T,例如需要实例化一个Tree类,需要用到的那个类是String,那么就可以这么来实例化Tree<String>()。

扩展资料:

定义分类

泛型的定义主要有以下两种:

1、在程序编码中一些包含类型参数的类型,也就是说泛型的参数只可以代表类,不能代表个别对象。(这是当今较常见的定义)

2、在程序编码中一些包含参数的类。其参数可以代表类或对象等等。(人们大多把这称作模板)不论使用哪个定义,泛型的参数在真正使用泛型时都必须作出指明。

一些强类型编程语言支持泛型,其主要目的是加强类型安全及减少类转换的次数,但一些支持泛型的编程语言只能达到部分目的。

参考资料来源:百度百科-泛型

关于java 中- gt 是什么意思,JAVA 中的 -> 是什么意思的介绍到此结束,希望对大家有所帮助。

java测试用什么软件 学软件测试好还是学java好三年java达到什么水平 Java工作3年是什么水平呢