the differences between groovy and java

YOLO26算法城市街道老年人目标检测+训练好的模型+219张数据集+pyqt可视化界面.zip 附训练好的 YOLO 权重与 PyQt 可视化检测界面,页面底部含可视化效果预览,毕设/课设开箱即用。 【数据集概况】 · 检测类别(中文):[老年人(grand)] · 总计:219 张 · 测试集:0 张 · 验证集:0 张 · 训练集:219 张 【训练曲线与评估图】 【模型训练配置】 参数 | 值 模型 | yolo26n 训练轮数 | 100 epochs 输入尺寸 | 640x640 批次大小 | 24 优化器 | auto 初始学习率 | 0.01 训练设备 【关键指标汇总】 训练了 100 个 epoch,最终轮指标: 指标 | 数值 mAP50 | **0.9933** mAP50-95 | 0.9400 Precision | 0.9766 Recall | 1.0000 train/box_loss | 0.3217 train/cls_loss | 0.2660 val/box_loss | 0.3492 val/cls_loss | 0.2783 【训练过程分析】 训练开始的第一周,模型的损失函数快速收敛,box_loss 和 cls_loss 在第 5 轮左右迅速降至较低值,这表明模型对基本的边界框和类别检测能力有了初步的把握。然而,到了第 10 轮,loss 开始缓慢下降,这表明模型可能已经开始遇到一些困难,例如类别间的区分度不够。整体看,损失函数在前 30 轮的快速下降阶段,帮助模型迅速学习了基本的检测规则。而在接下来的训练阶段,loss 的下降速度有所减缓,这显示模型进入了学习平台期。 在第 40 轮到第 50 轮,mAP50 逐渐提升并稳定在一个较高的水平,达到 0.9933,这表明模型在训练后期对小目标的检测能力提升显著。尽管 mAP50-95 有所提升,但也仅达到 ... 使用场景:毕业设计、课程设计、深度学习入门、工业场景落地验证。 立即下载

Groovy tries to be as natural as possible for Java developers. We’ve tried to follow the principle of least surprise when designing Groovy, particularly for developers learning Groovy who’ve come from a Java background.

Here we list all the major differences between Java and Groovy.

1. Default imports

All these packages and classes are imported by default, i.e. you do not have to use an explicit import statement to use them:

  • java.io.*

  • java.lang.*

  • java.math.BigDecimal

  • java.math.BigInteger

  • java.net.*

  • java.util.*

  • groovy.lang.*

  • groovy.util.*

2. Multi-methods

In Groovy, the methods which will be invoked are chosen at runtime. This is called runtime dispatch or multi-methods. It means that the method will be chosen based on the types of the arguments at runtime. In Java, this is the opposite: methods are chosen at compile time, based on the declared types.

The following code, written as Java code, can be compiled in both Java and Groovy, but it will behave differently:

int method(String arg) {
    return 1;
}
int method(Object arg) {
    return 2;
}
Object o = "Object";
int result = method(o);

In Java, you would have:

assertEquals(2, result);

Whereas in Groovy:

assertEquals(1, result);

That is because Java will use the static information type, which is that o is declared as an Object, whereas Groovy will choose at runtime, when the method is actually called. Since it is called with a String, then the String version is called.

3. Array initializers

In Groovy, the { …​ } block is reserved for closures. That means that you cannot create array literals with this syntax:

int[] array = { 1, 2, 3}

You actually have to use:

int[] array = [1,2,3]

4. Package scope visibility

In Groovy, omitting a modifier on a field doesn’t result in a package-private field like in Java:

class Person {
    String name
}

Instead, it is used to create a property, that is to say a private field, an associated getter and an associated setter.

It is possible to create a package-private field by annotating it with @PackageScope:

class Person {
    @PackageScope String name
}

5. ARM blocks

ARM (Automatic Resource Management) block from Java 7 are not supported in Groovy. Instead, Groovy provides various methods relying on closures, which have the same effect while being more idiomatic. For example:

Path file = Paths.get("/path/to/file");
Charset charset = Charset.forName("UTF-8");
try (BufferedReader reader = Files.newBufferedReader(file, charset)) {
    String line;
    while ((line = reader.readLine()) != null) {
        System.out.println(line);
    }

} catch (IOException e) {
    e.printStackTrace();
}

can be written like this:

new File('/path/to/file').eachLine('UTF-8') {
   println it
}

or, if you want a version closer to Java:

new File('/path/to/file').withReader('UTF-8') { reader ->
   reader.eachLine {
       println it
   }
}

6. Inner classes

The implementation of anonymous inner classes and nested classes follows the Java lead, but you should not take out the Java Language Spec and keep shaking the head about things that are different. The implementation done looks much like what we do for groovy.lang.Closure, with some benefits and some differences. Accessing private fields and methods for example can become a problem, but on the other hand local variables don’t have to be final.

6.1. Static inner classes

Here’s an example of static inner class:

class A {
    static class B {}
}

new A.B()

The usage of static inner classes is the best supported one. If you absolutely need an inner class, you should make it a static one.

6.2. Anonymous Inner Classes

import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit

CountDownLatch called = new CountDownLatch(1)

Timer timer = new Timer()
timer.schedule(new TimerTask() {
    void run() {
        called.countDown()
    }
}, 0)

assert called.await(10, TimeUnit.SECONDS)

6.3. Creating Instances of Non-Static Inner Classes

In Java you can do this:

public class Y {
    public class X {}
    public X foo() {
        return new X();
    }
    public static X createX(Y y) {
        return y.new X();
    }
}

Groovy doesn’t support the y.new X() syntax. Instead, you have to write new X(y), like in the code below:

public class Y {
    public class X {}
    public X foo() {
        return new X()
    }
    public static X createX(Y y) {
        return new X(y)
    }
}
Caution though, Groovy supports calling methods with one parameter without giving an argument. The parameter will then have the value null. Basically the same rules apply to calling a constructor. There is a danger that you will write new X() instead of new X(this) for example. Since this might also be the regular way we have not yet found a good way to prevent this problem.

7. Lambdas

Java 8 supports lambdas and method references:

Runnable run = () -> System.out.println("Run");
list.forEach(System.out::println);

Java 8 lambdas can be more or less considered as anonymous inner classes. Groovy doesn’t support that syntax, but has closures instead:

Runnable run = { println 'run' }
list.each { println it } // or list.each(this.&println)

8. GStrings

As double-quoted string literals are interpreted as GString values, Groovy may fail with compile error or produce subtly different code if a class with String literal containing a dollar character is compiled with Groovy and Java compiler.

While typically, Groovy will auto-cast between GString and String if an API declares the type of a parameter, beware of Java APIs that accept an Object parameter and then check the actual type.

9. String and Character literals

Singly-quoted literals in Groovy are used for String, and double-quoted result in String or GString, depending whether there is interpolation in the literal.

assert 'c'.getClass()==String
assert "c".getClass()==String
assert "c${1}".getClass() in GString

Groovy will automatically cast a single-character String to char only when assigning to a variable of type char. When calling methods with arguments of type char we need to either cast explicitly or make sure the value has been cast in advance.

char a='a'
assert Character.digit(a, 16)==10 : 'But Groovy does boxing'
assert Character.digit((char) 'a', 16)==10

try {
  assert Character.digit('a', 16)==10
  assert false: 'Need explicit cast'
} catch(MissingMethodException e) {
}

Groovy supports two styles of casting and in the case of casting to char there are subtle differences when casting a multi-char strings. The Groovy style cast is more lenient and will take the first character, while the C-style cast will fail with exception.

// for single char strings, both are the same
assert ((char) "c").class==Character
assert ("c" as char).class==Character

// for multi char strings they are not
try {
  ((char) 'cx') == 'c'
  assert false: 'will fail - not castable'
} catch(GroovyCastException e) {
}
assert ('cx' as char) == 'c'
assert 'cx'.asType(char) == 'c'

10. Primitives and wrappers

Because Groovy uses Objects for everything, it autowraps references to primitives. Because of this, it does not follow Java’s behavior of widening taking priority over boxing. Here’s an example using int

int i
m(i)

void m(long l) {           
  println "in m(long)"
}

void m(Integer i) {        
  println "in m(Integer)"
}
This is the method that Java would call, since widening has precedence over unboxing.
This is the method Groovy actually calls, since all primitive references use their wrapper class.

11. Behaviour of ==

In Java == means equality of primitive types or identity for objects. In Groovy == translates to a.compareTo(b)==0, if they are Comparable, and a.equals(b) otherwise. To check for identity, there is is. E.g. a.is(b).

12. Conversions

Java does automatic widening and narrowing conversions.

Table 1. Java Conversions
 

Converts to

Converts from

boolean

byte

short

char

int

long

float

double

boolean

-

N

N

N

N

N

N

N

byte

N

-

Y

C

Y

Y

Y

Y

short

N

C

-

C

Y

Y

Y

Y

char

N

C

C

-

Y

Y

Y

Y

int

N

C

C

C

-

Y

T

Y

long

N

C

C

C

C

-

T

T

float

N

C

C

C

C

C

-

Y

double

N

C

C

C

C

C

C

-

* 'Y' indicates a conversion Java can make, 'C' indicates a conversion Java can make when there is an explicit cast, 'T` indicates a conversion Java can make but data is truncated, 'N' indicates a conversion Java can’t make.

Groovy expands greatly on this.

Table 2. Groovy Conversions
 

Converts to

Converts from

boolean

Boolean

byte

Byte

short

Short

char

Character

int

Integer

long

Long

BigInteger

float

Float

double

Double

BigDecimal

boolean

-

B

N

N

N

N

N

N

N

N

N

N

N

N

N

N

N

N

Boolean

B

-

N

N

N

N

N

N

N

N

N

N

N

N

N

N

N

N

byte

T

T

-

B

Y

Y

Y

D

Y

Y

Y

Y

Y

Y

Y

Y

Y

Y

Byte

T

T

B

-

Y

Y

Y

D

Y

Y

Y

Y

Y

Y

Y

Y

Y

Y

short

T

T

D

D

-

B

Y

D

Y

Y

Y

Y

Y

Y

Y

Y

Y

Y

Short

T

T

D

T

B

-

Y

D

Y

Y

Y

Y

Y

Y

Y

Y

Y

Y

char

T

T

Y

D

Y

D

-

D

Y

D

Y

D

D

Y

D

Y

D

D

Character

T

T

D

D

D

D

D

-

D

D

D

D

D

D

D

D

D

D

int

T

T

D

D

D

D

Y

D

-

B

Y

Y

Y

Y

Y

Y

Y

Y

Integer

T

T

D

D

D

D

Y

D

B

-

Y

Y

Y

Y

Y

Y

Y

Y

long

T

T

D

D

D

D

Y

D

D

D

-

B

Y

T

T

T

T

Y

Long

T

T

D

D

D

T

Y

D

D

T

B

-

Y

T

T

T

T

Y

BigInteger

T

T

D

D

D

D

D

D

D

D

D

D

-

D

D

D

D

T

float

T

T

D

D

D

D

T

D

D

D

D

D

D

-

B

Y

Y

Y

Float

T

T

D

T

D

T

T

D

D

T

D

T

D

B

-

Y

Y

Y

double

T

T

D

D

D

D

T

D

D

D

D

D

D

D

D

-

B

Y

Double

T

T

D

T

D

T

T

D

D

T

D

T

D

D

T

B

-

Y

BigDecimal

T

T

D

D

D

D

D

D

D

D

D

D

D

T

D

T

D

-

* 'Y' indicates a conversion Groovy can make, 'D' indicates a conversion Groovy can make when compiled dynamically or explicitly cast, 'T` indicates a conversion Groovy can make but data is truncated, 'B' indicates a boxing/unboxing operation, 'N' indicates a conversion Groovy can’t make.

The truncation uses Groovy Truth when converting to boolean/Boolean. Converting from a number to a character casts the Number.intvalue() to char. Groovy constructs BigInteger and BigDecimal using Number.doubleValue() when converting from a Float or Double, otherwise it constructs using toString(). Other conversions have their behavior defined by java.lang.Number.

13. Extra keywords

There are a few more keywords in Groovy than in Java. Don’t use them for variable names etc.

  • as

  • def

  • in

  • trait

东汉AD188年世界历史地图矢量文件SHP格式.zip 本资源为《东汉AD188年世界历史地图矢量文件SHP格式》压缩包,文件大小约 28.55 MB,便于集中下载、整理和使用。具体内容请结合压缩包内的实际文件与说明查看。 在当前可读取的目录中,可见属性表(.dbf)、投影说明文件(.prj)、Shapefile 主文件(.shp)、Shapefile 索引(.shx)。建议解压后保持原有目录结构,先浏览文件清单与说明,再选择需要的资料进行加载或整理。 应用方面,可根据实际资料用于学习练习、资料检索、研究整理或项目参考。使用时可先确定所需内容,建立清晰的文件分类,再按项目要求进行筛选、转换与汇总。 使用 Shapefile 数据时,请把实际配套的 .shp、.shx、.dbf 等文件保存在同一目录,并保持同名关联;加载后再检查坐标系与中文字段显示。如需叠加其它数据,请先统一坐标与字段口径。 数据来源、时间范围、坐标系、字段定义、精度和使用条件,请以实际文件及原始说明为准。本介绍不对文件名之外尚未核实的信息作额外承诺。 立即下载

相关推荐

13 《脱敏演讲训练感悟》 教培机构校长 台下不是学生.docx

13 《脱敏演讲训练感悟》 教培机构校长 台下不是学生

java中assignments,Operators and Assignments(2)-JSP教程,Java基础

objective 2)determine the result of applying the boolean equals(object) method to objects of any combination of the classes java.lang.string java.lang.boolean and java.lang.object.the equals method ca...

weixin_31111259的博客 342

【创新未发表】绿电直连型电氢氨园区优化运行研究(Matlab代码、Python、数据、word论文)

内容概要:本文围绕“绿电直连型电氢氨园区优化运行”展开研究,提出一种集成绿色电力直接连接电解水制氢、合成氨的综合能源系统优化运行模型。研究构建了涵盖风电、光伏等可再生能源出力不确定性、电解槽制氢效率特性、氨合成能耗及多能存储协同调度的数学模型,并采用Matlab与Python进行联合仿真,结合实际气象与电价数据对系统经济性、能效与碳减排性能进行全面评估。文中提供了完整的代码、数据集及Word论文,重点探讨了源-荷-储协调机制、能量转化设备的运行策略以及多目标优化求解方法,旨在提升园区能源自给率与低碳水平。; 适合人群:具备一定电力系统、能源工程或优化算法基础的研究生、科研人员及从事新能源系统规划的技术人员。; 使用场景及目标:①用于开展可再生能源耦合氢能与化工生产的综合能源系统建模与仿真;②支撑低碳工业园区、零碳示范区的规划设计与运行优化研究;③作为学习多能互补系统优化、电氢氨协同调度的实践案例。; 阅读建议:建议结合提供的Matlab代码与Python脚本,逐步调试运行模型,重点关注目标函数构建、约束条件设置及求解器调用逻辑,同时参考论文部分深入理解模型设计思路与实际应用场景。

Cannot use ‘<>‘ with anonymous inner classes

将Java环境由Java8改为Java9.

pxyyoona的博客 1573

同花顺【红绿趋势】幅图指标 源码分析

a10:IF(差值<=0 ,0 ,差值*0.2 ,4 ,0),STICK,linethick5,colorred;a7:IF(差值<=0 ,0 ,差值*0.8 ,4 ,0),STICK,linethick5,colorred;a8:IF(差值<=0 ,0 ,差值*0.6 ,4 ,0),STICK,linethick5,colorred;a6:IF(差值<=0 ,0 ,差值*1 ,4 , 0),STICK,linethick5,colorred;DRAWICON(先锋<0,-25,1);

zhibiaogong的博客 4122

VideoPose3d:环境搭建+制作自己的视频

论文链接:3D human pose estimation in video with temporal convolutions and semi-supervised training 代码链接:https://github.com/facebookresearch/VideoPose3D 环境搭建:ubuntu20.04+pytorch1.8+cuda10.2+python3.6+anaconda 1.启动anaconda环境 新建环境命令: conda create -n pytorc.

willbetter01的博客 4951

Java 8 Lamda

Java 8 Lamdawe all know Lambda project is a big enhancement to the java programming language. so let’s start to learn the grammer.Backgroundjava is, an object-oriented programming language. but the lan

fly1056601582的博客 499

RK356X linux系统移植RTL8723BU模块遇到的坑

RK356X linux系统移植RTL8723BU模块遇到的坑

目前从事linux驱动开发,多交流多学习吧 961

ioS开发--Warning警告处理

去除警告的方法: #pragma clang diagnostic push #pragma clang diagnostic ignored"-Wunused-function" local void free_linkedlist(ll) linkedlist_data* ll; { free_datablock(ll->first_block); ll->first_blo

zzzzzdddddxxxxx的专栏 1万+

ESP32-S3模组上跑通esp32-camera(32)

ESP32-S3模组上跑通esp32-camera(32)

phmatthaus的专栏 780

Unity 之如何使用Pico4u锚点功能实现一个世界锁GameRoot

摘要 空间锚点技术是混合现实(MR)应用的核心,能永久记录虚拟物体的空间位置。文章介绍了在Unity中使用Pico SDK实现空间锚点的完整流程:1)环境配置需安装XR模块和Pico SDK;2)关键操作包括启动空间感知、创建/删除/查询/更新锚点;3)提供了经典应用案例,通过GameRoot节点实现场景固定和锚点同步。源码展示了基于XR交互工具包的锚点抓取与位置更新实现,为MR开发提供了实用参考方案。

TxNet 991

Literal Values

Integer LiteralsInteger literals can be expressed in decimal, hexadecimal, or octal.You indicate a negative number by prefixing the literal with a – sign.For Long literals, it is necessary to append th

BrownWong的专栏 1366

2026年瑞芯微数字IC设计笔试试卷带答案

本文主要考察数字集成电路设计相关知识,包括低功耗设计、时序分析、跨时钟域处理、总线协议等内容。试题分为单选题、多选题、代码设计题和简答题四部分。 单选题涉及门控时钟降低动态功耗、静态时序分析的限制、跨时钟域同步方案、时序违例修复方法、AHB总线信号、异步FIFO设计、半导体工艺电阻特性、二进制数转换、同步/异步复位比较以及分频电路设计等知识点。 多选题重点考查动态功耗优化技术、亚稳态特性、异步FIFO设计规范、Verilog可综合代码编写要求以及AXI总线协议特点等。 代码设计题要求实现一个同步FIFO和3

Open 226

Differences between Java and Groovy

Differences with Java Groovy tries to be as natural as possible for Java developers. We’ve tried to follow the principle of least surprise when designing Groovy, particularly for developers l...

博客颜色 206

鲁棒控制理论 --- H∞ 控制(被裁篇)

鲁棒控制理论 --- H∞ 控制

记录老板的每次pua,分享领导每天的毒鸡汤... 6万+

echarts 饼图(加载进度条动画效果)

1、外侧动画细线效果运动“custom”自定义系列中“renderItem”属性来实现,动态修改起始角度和终止角度。2、圆环使用" pie "类型添加两个data值来画百分比圆环,动态修改data中的值。

God's asylum的博客 1638

Java Wish List: The Top Differences Between Java, Scala, Groovy, Clojure and Kotlin

A list of the top differences between Java, Scala, Groovy, Clojure and Kotlin It doesn’t matter if you’re developing in Java, Scala or any other JVM languages, there’s always something new to learn

mark's technic world 810

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

从Java到Groovy——Differences with Java

Groovy与Java的比较

xu_fu的专栏 978

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Groovy Differences with Java(Groovy不同于java的地方)

Groovy tries to be as natural as possible for Java developers. We’ve tried to follow the principle of least surprise when designing Groovy, particularly for developers learning Groovy who’ve come from

doubleping的专栏 642

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Groovy 语言本身具有简洁、灵活的特点,使得测试代码的编写更加高效

- **丰富的框架、库和工具**:Groovy 社区非常活跃,开发出了大量的框架、库和工具。这为开发者提供了丰富的选择,能够满足不同场景下的开发需求,从而提高开发效率。

[Blog][Domain] programb.blog.csdn.net 475

Torchvision 数据集 API 文档生成机制:深入解析 class_dataset.rst 的 Sphinx autodoc 模板

`docs/source/_templates/class_dataset.rst` 是 Torchvision 文档构建体系中负责自动生成**数据集(Dataset)类 API 参考页面**的 Sphinx 模板:每当 `docs/source/datasets.rst` 中通过 `autosummary` 罗列一个数据集类(如 `CIFAR10`、`INaturalist`、`KittiFlo

gitblog_00198的博客 354

终极WinMerge过滤器指南:告别冗余文件干扰的7个实用技巧

你是否曾在使用WinMerge进行文件夹比对时,被大量无关的日志文件、编译产物和缓存文件淹没,导致真正重要的差异被隐藏?作为Windows平台上最强大的开源差异比较工具,WinMerge的过滤器功能正是解决这一痛点的终极利器。本文将为你详细介绍如何利用WinMerge过滤器精准排除干扰文件,通过7个实用技巧让文件夹比对效率提升80%,专注于真正需要关注的差异。 ## 用户痛点分析:为什么你需要过

gitblog_00481的博客 310

JMeter集成Python操作DB2数据库:提升性能测试脚本灵活性与数据处理能力

在性能测试与接口自动化领域,数据库操作是核心环节。关系型数据库如DB2,其连接与操作通常依赖JDBC等标准接口,但面对复杂的数据生成、JSON/XML解析或特定SQL逻辑时,脚本的灵活性与可维护性面临挑战。此时,引入Python这一具备丰富生态的脚本语言,通过其pandas、sqlalchemy等库,可以高效处理数据构造与比对等复杂任务。其技术价值在于,将JMeter的负载模拟调度能力与Python强大的数据处理能力相结合,形成优势互补的工程实践方案。这一模式特别适用于需要在压测前后进行自动化数据准备、校验

weixin_33681778的博客 369

Objective-C 警告相关说明

原文地址:http://nshipster.com/clang-diagnostics/

2万+

Groovy Convert between string and date

Reference: http://java.dzone.com/articles/groovy-jdk-gdk-date-and http://www.javabeat.net/2008/09/sample-code-for-simpledateformat/ //String to Date import java.util.Date def newDate ='

markinlqx的专栏 3216

Groovy入门

groovy

建伟博客 1159
上一篇: 案例研究:利用Grails搭建Feedlr.com网站
下一篇: Groovy与Java的区别
hxpjava1
博客等级 码龄19年 1365粉丝 511原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址