Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7982893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:48:28+00:00 2026-06-04T10:48:28+00:00

The code: String s = \d; raises an compiler error, illegal escape character. Ok

  • 0

The code:

String s = "\d";

raises an compiler error, illegal escape character. Ok understood!!

But the code:

class Test
{
public static void main(String[] args)
{
String s = args[0];
System.out.println(s);
}
}

does not when invoked with the command java Test \d or java Test "\d". Why??

Infact it even prints: \d without using the double back-slashes (“\\d”).

Aren’t the arguments provided via command-line treated as Strings only?

I know it can’t raise a compiler error because arguments provided at command-line are after compilation stage but then shouldn’t it raise a runtime exception or something??

Or is it that once we have passed through the compilation stage it doesn’t matter what the String contains (because the code is converted in bytecode and the whole code structure is altered)? If yes, then can someone please elaborate.

Thnx in advance!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:48:30+00:00Added an answer on June 4, 2026 at 10:48 am

    You don’t realise that shell command lines and Java are two different languages. A command line given to a shell is parsed as a shell command. A Java program given to java is parsed as Java.

    You are possibly also confusing strings literals (pieces of code that produce strings) and strings (values consisting of a sequence of characters).

    You want the two character string \d to be stored in variable s. You need to construct an appropriate string literal in order to do that.

    • To produce the two character string \d, one can use a cmd (Windows shell) string literal \d.
    • To produce the two character string \d, one can use a Java string literal "\\d".
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using this code to fetch the processor id: public static string getProcessorId() {
I have the following code string three() { return three; } void mutate(string& ref)
I have the following DTO definition:- [DataContract] public class AddProductDTO { [DataMember] public string
Here's the code: string name = myName; int id = (int)_myDB.ThingTable.Where(thing => thing.ThingName ==
I have the following code: string acctStatus = account.AccountStatus.ToString(); if (!SettableStatuses().Any(status => status ==
I have the following code: String serviceType; ServiceBrowser tmpBrowser; for (String playerName: players) {
Here is the code: string str; cin>>str; cout<<first input:<<str<<endl; getline(cin, str); cout<<line input:<<str<<endl; The
Suppose I have this code: String encoding = UTF-16; String text = [Hello StackOverflow];
I have the following code: string[] firstArray = { bla bla, bla bla, bla
I have this code : String check=SELECT COUNT(*) as check FROM recordstudent WHERE STUDENT_ID=+T_STUDENT_ID+

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.