473,509 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

In java, not in c#


Create a method BBB

private String BBB(String s)
{
return s + "hello";
}

Then call the method with

String BBB = BBB(company);
This will work in java, but not in c#;
Nov 22 '05 #1
11 1630
Are you asking a question, or just telling us this information?

"John Bailo" <ja*****@earthlink.net> wrote in message
news:2s*************@uni-berlin.de...

Create a method BBB

private String BBB(String s)
{
return s + "hello";
}

Then call the method with

String BBB = BBB(company);
This will work in java, but not in c#;

Nov 22 '05 #2
Are you asking a question, or just telling us this information?

"John Bailo" <ja*****@earthlink.net> wrote in message
news:2s*************@uni-berlin.de...

Create a method BBB

private String BBB(String s)
{
return s + "hello";
}

Then call the method with

String BBB = BBB(company);
This will work in java, but not in c#;

Nov 22 '05 #3
"John Bailo" <ja*****@earthlink.net> wrote in message
news:2s*************@uni-berlin.de...

Create a method BBB

private String BBB(String s)
{
return s + "hello";
}

Then call the method with

String BBB = BBB(company);
This will work in java, but not in c#;


Since 'company' is an undeclared variable, it won't compile in either.

Perhaps you'd like to construct a complete example?
Nov 22 '05 #4
"John Bailo" <ja*****@earthlink.net> wrote in message
news:2s*************@uni-berlin.de...

Create a method BBB

private String BBB(String s)
{
return s + "hello";
}

Then call the method with

String BBB = BBB(company);
This will work in java, but not in c#;


Since 'company' is an undeclared variable, it won't compile in either.

Perhaps you'd like to construct a complete example?
Nov 22 '05 #5
Mike Schilling wrote:
"John Bailo" <ja*****@earthlink.net> wrote in message
news:2s*************@uni-berlin.de...
Create a method BBB

private String BBB(String s)
{
return s + "hello";
}

Then call the method with

String BBB = BBB(company);
This will work in java, but not in c#;

Since 'company' is an undeclared variable, it won't compile in either.

Perhaps you'd like to construct a complete example?

try this then:

private String BBB(String s)
{
return s + "hello";
}

private void myCall()
{
String company="Texeme";
String BBB = BBB(company);
}
Nov 22 '05 #6
Mike Schilling wrote:
"John Bailo" <ja*****@earthlink.net> wrote in message
news:2s*************@uni-berlin.de...
Create a method BBB

private String BBB(String s)
{
return s + "hello";
}

Then call the method with

String BBB = BBB(company);
This will work in java, but not in c#;

Since 'company' is an undeclared variable, it won't compile in either.

Perhaps you'd like to construct a complete example?

try this then:

private String BBB(String s)
{
return s + "hello";
}

private void myCall()
{
String company="Texeme";
String BBB = BBB(company);
}
Nov 22 '05 #7
John Bailo <ja*****@earthlink.net> writes:
String BBB = BBB(company);


You can work around the "feature" using this.BBB(company), but it's
still somewhat puzzling, yes.
Nov 22 '05 #8
John Bailo <ja*****@earthlink.net> writes:
String BBB = BBB(company);


You can work around the "feature" using this.BBB(company), but it's
still somewhat puzzling, yes.
Nov 22 '05 #9

"Tor Iver Wilhelmsen" <to*****************@broadpark.no> wrote in message
news:uu***********@broadpark.no...
John Bailo <ja*****@earthlink.net> writes:
String BBB = BBB(company);


You can work around the "feature" using this.BBB(company), but it's
still somewhat puzzling, yes.


It likely stems from delegate invocation syntax.

In C# its entirely legal to do something like:

MyDelegate BBB = new MyDelegate(this.BBB);
BBB("company");

Thus, an invocation expression on a variable is legal in *some* situations,
so the particular example given is ambiguous in *some* cases.

Instead of trying to guess, the compiler does the right thing and picks the
variable instead of the member function.
Nov 22 '05 #10

"Tor Iver Wilhelmsen" <to*****************@broadpark.no> wrote in message
news:uu***********@broadpark.no...
John Bailo <ja*****@earthlink.net> writes:
String BBB = BBB(company);


You can work around the "feature" using this.BBB(company), but it's
still somewhat puzzling, yes.


It likely stems from delegate invocation syntax.

In C# its entirely legal to do something like:

MyDelegate BBB = new MyDelegate(this.BBB);
BBB("company");

Thus, an invocation expression on a variable is legal in *some* situations,
so the particular example given is ambiguous in *some* cases.

Instead of trying to guess, the compiler does the right thing and picks the
variable instead of the member function.
Nov 22 '05 #11
That's good for java.. It really is..

Practically however, if you where naming functions correctly, you would use
a verb for the method.. You know what a verb is, it's a doing word.. i.e.
GetSomething, DoSomething, CalculateSomething...
Compare that to a variable which is normal just a name...

Not only that, you should also consider clarity of code.. Most coding
standards (regardless of company) have different naming conventions that
prevent this sort of conflict, normally through casing and prefixing of
variables...

Personally, I think if you ever get confused with something like this, or if
you think this is a serious problem, then the code you are writing is most
likely very unmaintainable...

Just my 2c..

Eddie de Bear

"John Bailo" wrote:

Create a method BBB

private String BBB(String s)
{
return s + "hello";
}

Then call the method with

String BBB = BBB(company);
This will work in java, but not in c#;

Nov 22 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
6785
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
1
6900
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
11
9212
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
0
5640
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
1
9586
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
12
5893
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it...
0
3250
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build...
1
4288
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in...
0
3237
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7416
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3218
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1571
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.