DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Data Engineering
  3. Databases
  4. Uses for Special Characters in Java Code

Uses for Special Characters in Java Code

Peter Lawrey user avatar by
Peter Lawrey
·
Aug. 14, 12 · Interview
Like (0)
Save
Tweet
Share
23.88K Views

Join the DZone community and get the full member experience.

Join For Free
Ever wondered how you can write code like this in Java?
    if( ⁀ ‿ ⁀ == ⁀ ⁔ ⁀ || ¢ + ¢== ₡)

Background

Underscores has long been using in C like language such as Java to distinguish fields and method names.

It is common to see a leading underscore like _field or an underscore in a constant like UPPER_CASE. In Java the $ is also used in class names and accessor method names.

The SCJP has notes which state

Identifiers must start with a letter, a currency character ($), or a connecting character such as the underscore ( _ ). Identifiers cannot start with a number!
This leads to the question; what other connecting characters are there?

What are connecting characters?

A connecting character joins two words together. This page lists ten connecting characters

U+005F LOW LINE _ view
U+203F UNDERTIE ‿ view
U+2040 CHARACTER TIE ⁀ view
U+2054 INVERTED UNDERTIE ⁔ view
U+FE33 PRESENTATION FORM FOR VERTICAL LOW LINE ︳ view
U+FE34 PRESENTATION FORM FOR VERTICAL WAVY LOW LINE ︴ view
U+FE4D DASHED LOW LINE ﹍ view
U+FE4E CENTRELINE LOW LINE ﹎ view
U+FE4F WAVY LOW LINE ﹏ view
U+FF3F FULLWIDTH LOW LINE _ view

And if you try the following you may find it compiles.

     int _, ‿, ⁀, ⁔, ︳, ︴, ﹍, ﹎, ﹏, _;

While this is interesting, does it have a use?  Recently I found one.
I have an object which represents a column, and this column has a value for that row. The names are basically the same but I want a notation to distinguish them. So I have something like
    Column<Double>︴tp︴ = table.getColumn("tp", double.class);
    double tp = row.getDouble(︴tp︴);

This way I can see with is tp the column, and which is the value.

Interestingly the currency characters are valid as well.
 for (int i = Character.MIN_CODE_POINT; i <= Character.MAX_CODE_POINT; i++)
        if (Character.isJavaIdentifierStart(i) && !Character.isAlphabetic(i))
            System.out.println(i + " : " + (char) i);

prints

36 : $
95 : _
162 : ¢
163 : £
164 : ¤
165 : ¥
1547 : ؋
2546 : ৲
2547 : ৳
2555 : ৻
2801 : ૱
3065 : ௹
3647 : ฿
6107 : ៛
8255 : ‿
8256 : ⁀
8276 : ⁔
8352 : ₠
8353 : ₡
8354 : ₢
8355 : ₣
8356 : ₤
8357 : ₥
8358 : ₦
8359 : ₧
8360 : ₨
8361 : ₩
8362 : ₪
8363 : ₫
8364 : €
8365 : ₭
8366 : ₮
8367 : ₯
8368 : ₰
8369 : ₱
8370 : ₲
8371 : ₳
8372 : ₴
8373 : ₵
8374 : ₶
8375 : ₷
8376 : ₸
8377 : ₹
43064 : ꠸
65020 : ﷼
65075 : ︳
65076 : ︴
65101 : ﹍
65102 : ﹎
65103 : ﹏
65129 : ﹩
65284 : $
65343 : _
65504 : ¢
65505 : £
65509 : ¥
65510 : ₩
Java (programming language) Database

Published at DZone with permission of Peter Lawrey, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The 12 Biggest Android App Development Trends in 2023
  • Hidden Classes in Java 15
  • Remote Debugging Dangers and Pitfalls
  • How Observability Is Redefining Developer Roles

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: