• Post Reply Bookmark Topic Watch Topic
  • New Topic

I found a solution to my earlier thread mentioned herein  RSS feed

 
Rajib Ban
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The said earlier thread here is Can one not learn Java without knowing C? And C without machine or assembly languages?
The thread at the Eclipse Forum was solved by a poster there, where I also had placed a copy of the thread, looking at the mess being created here.
The Eclipse thread is here: Can one not learn Java without knowing C? And C without machine or assembly languages?

The solution to the problem I had faced here is as follows:
...look at this portion:
The main method accepts a single argument: an array of elements of type String.

public static void main(String[] args)


My question is: If the main method accepts only a single argument, how come it is an array of elements of the type string. There should only be one array of type String, an array having many character elements. So the statement should have been:
The main method accepts a single argument: an array of elements characters of type forming a String.

public static void main(String[] args)
...

I lately discovered that I was not allowed to post further onto that thread of mine. For six hours I tried to post unsuccessfully there, reading that there was a CSRF error. There wasn't! I was barred without infomation.

I found that the Eclipse forum is visually attractive and easier to have my posts formatted and edited and re-edited and improved.

I was thinking if I could post my queries there with a link of that query here, as I have a lot of restrictions here.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66158
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajib Ban wrote:There should only be one array of type String, an array having many character elements. So the statement should have been:

Incorrect. The array is of String objects, not of individual characters.

I lately discovered that I was not allowed to post further onto that thread of mine. For six hours I tried to post unsuccessfully there, reading that there was a CSRF error. There wasn't! I was barred without information.

Incorrect again. If you were banned from these forums, it would not take the form of CSRF errors.
 
Zachary Griggs
Ranch Hand
Posts: 82
10
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The people posting in that thread explained it quite clearly.

While a String does use an array of characters internally, args[] is not actually an array of characters. It is an array of Strings, which are an Object that internally uses an array of characters to represent it. There's no difference in C because there aren't any objects, but here there is. For example, you can call instance methods on Strings to create new ones based off the old, and such like that. Java is not the same as C, your knowledge of C strings doesn't apply here.
 
Rajib Ban
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Incorrect. The array is of String objects, not of individual characters.


In that case the sentence should have been:
The main method accepts a single argument: an array of multiple String objects.

public static void main(String[] args)
 
Zachary Griggs
Ranch Hand
Posts: 82
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is just another way of saying what the original sentence said - but yes that is correct.
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This Java™ Tutorials section would appear to be where the quote about array of Strings come from.
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajib Ban wrote:. . . there was a CSRF error . . . I have a lot of restrictions here.
If there was a CSRF error, that was caused by incorrect posting technique.
No, we do not have a lot of restrictions. nor have we applied any restrictions to you.
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From The Eclipse forum
An array is simply an allocated space in memory dedicated to your desired memory type, in this case a string. A string is an array of characters.
I am pretty sure both those statements, unfortunately, are incorrect for Java®. Certainly the second sentence there differs from the Java® Language Specification.
The Same Source wrote:Java MyApp arg1 arg2 simply means you have a Java program called MyApp that takes two arguments.
That presumably differs from language to language; in Java® however there is only one argument which is a String[]. I think the poster in that forum is confusing the Java® requirements with the conventions in C; the two are unrelated languages, so what applies n C might not apply in Java®.
 
Campbell Ritchie
Sheriff
Posts: 55351
157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OP: Kindly read this, this and this.
 
Rajib Ban
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:OP: Kindly read...[/url].

Okay, thanks!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!