PDA

View Full Version : Is Java and C++....


marx123
12-06-2006, 08:22 AM
Is Java and C++ the same

because im studying on a course
im now on the part of Variables...

ractoc
12-06-2006, 02:04 PM
No definately not. There's loads of differences between Java and C++. For instance, Java is an OO language, C++ can be used to program OO.

But the biggest difference when it comes to variables would be that C++ has pointers and Java does not. At least not in a way that you can directly manipulate them.

naruto1327
12-06-2006, 11:50 PM
C++ is OO too...

lothia
12-07-2006, 03:01 AM
hmm if you are talking about the basics, they are almost the same. As in the way you program and think. Pointers are considered beginner as well but we will exclude that. Any ways they are close but not any where near the same, if you can read one you can read the other.

marx123
12-07-2006, 07:32 AM
hmm if you are talking about the basics, they are almost the same. As in the way you program and think. Pointers are considered beginner as well but we will exclude that. Any ways they are close but not any where near the same, if you can read one you can read the other.

oh okay

by the what is the use of

include [iostream]

name spacestd;

Class Car

every time i compile that..its says the Class Car is incorrect...

lothia
12-08-2006, 03:00 AM
hmm no idea what a Class car is, I havn't done C++ for a while but the include [iostream] if I remember correctly is automaticly adding a premade file which allows you to do the cin, cout etc.
In java you do not require anything like that, but you create everything in classes. How ever variables are the same as far as I have noticed. Not any different ones in either, Arrays are different in how you call them though (but that holds multiple variables)

marx123
12-08-2006, 10:17 PM
hmm no idea what a Class car is, I havn't done C++ for a while but the include [iostream] if I remember correctly is automaticly adding a premade file which allows you to do the cin, cout etc.
In java you do not require anything like that, but you create everything in classes. How ever variables are the same as far as I have noticed. Not any different ones in either, Arrays are different in how you call them though (but that holds multiple variables)

i guess...
for variables

is salary a variable?
i talk to my professor about this..he doesnt answer me..i dont know why....
i bet he hates me dunno?

gee lothia..if i have some questions i post a thread here regarding C++

thanks

lothia
12-09-2006, 06:40 AM
hmm well you can have a variable called salary.
It would probably be a double. Which would be called by
double salary;
or
double salary = <value>

hmm thats java actually but last time I checked calling them is the same.

masterarcher
12-28-2006, 01:12 AM
Java and C++ same? Nope, they aren't. They are both based upon C but that doesn't make them same. The major differences are that C++ supports Multiple Inheritance and Genericity while Java doesn't and Java supports persistence which C++ doesn't. Java is a pure Object Oriented Language while C++ isn't (it can only be used to program OO, its not pure OOP). C++ has pointers, not Java. And pointers are important, that's what makes C++ programs faster and efficient than Java ones when the size gets bigger. You include header files like #include <iostream> in preprocessor in C++, not Java. In Java, you use something like import java.lang.*;. There's major syntactical difference between the languages too. Java boasts that programs can be made by using shorter codes than C++, and it does require less amount of code than C++. Other than these major differences though, they are much similar. That doesn't mean they are same though, heck, if they were same, Java, (most of the) programs made by which can run easily inside a web browser would have overtaken C++ ages ago.

Cj Shadows
12-28-2006, 09:27 PM
Java hides some things that C++ doesnt. But you use "using namespace std;" so when you do somthing with iostream like "cout" you just have to put "cout" instead of "std::cout".

hamik
12-28-2006, 09:51 PM
by the what is the use of

include [iostream]

name spacestd;

Class Car

every time i compile that..its says the Class Car is incorrect...

Ok First of all its
1)#include <iostream> that is a header basically it has some functions inside of it you can use such as cout and cin(which display text on the screen and recieve input). For every library you use you must include the header with #include.

2)using namespace std; is the correct way of doing it. For the iostream header you need this to use cout, cin, and other functions in the iostream header.

3)The reason you get an error is because when you type "Class car" your making a class called car and you haven't added anything inside of it. Here is something it could look like.
Class Car
{
private:
int x1,y1;
int x2,y2;
int miles;
double milespergallon;
public:
int distancefind(x1,x2,y1,y2)
{ yadaya finds distance
returns distance;}

4) There is no salary variable unless you declare it and there is no type of variable called salary.

Cj Shadows
12-29-2006, 12:45 AM
Good explanation hamik, but Im not sure or saying your wrong but don't you have to do int Class Car? or just int Car to make it work?

naruto1327
12-30-2006, 04:09 AM
Good explanation hamik, but Im not sure or saying your wrong but don't you have to do int Class Car? or just int Car to make it work?

Just Class Car. He's declaring the Class "Car" by doing:

Class Car
{
private:
int x1,y1;
int x2,y2;
int miles;
double milespergallon;
public:
int sumOfX1Y1(x1,y1) {return x1 + y1;}
}

If he were to instantiate an object, he would simply do:

Car myCar;

If you did this:

int Class Car;

Then the compiler would think that you are trying to create a type int variable with the name Class Car. For example, suppose you want to declare an int type variable with the value equal to the number of pies you have. You can't just do "int numOfPies 3", you have to do "int numOfPies = 3;". So, basically, "int Class Car" doesn't make any sense.

Correct me if I'm wrong though o.o. My C++ is gettin' rusty. ><

Cj Shadows
12-30-2006, 05:29 AM
Ah okay, well Im just learning. Im on varibles.

masterarcher
01-03-2007, 02:16 AM
The reason its not int class car is that C++ is made in such a way that it treats user built types nearly as well as built in data types. So, a Class named car declares a new data type called car which is now equivalent of any other built in data type. Since car is itself a data type, how can it be declared as an int type? Classes have their own memory allocation while any int types have only 32 bits of memory available(unless declared as short, long or unsigned).

Renamation
01-03-2007, 08:35 AM
java uses its own script codes and C++ is programming

masterarcher
01-10-2007, 12:55 AM
java uses its own script codes and C++ is programming
Java is programming too(or whatever you meant by C++ is programming, programming what?). You can use it to make a new program as required by you, so, it involves programming too, it has all the major features of a programming language, how can you say its not programming lol, don't tell me you were taking Java for Javascript..

Dennis56
01-13-2007, 05:42 AM
java uses its own script codes and C++ is programming

wow do you have any idea what java is?

Cj Shadows
01-13-2007, 05:37 PM
Maybe he is confusing it with Javascript?

Khanstruct
01-14-2007, 04:03 AM
Absolutely. Java and C++ are very similar. Javascript, however, is a totally different story. Just like VBScript. While people that know VB may understand VBScript, its not quite the same, and has completely different uses.

Java is the language that we're programming our MMORPG in. I would not, on the other hand, attempt such a feat with Javascript.

lothia
01-16-2007, 04:14 PM
Well since this topic for what ever reason is staying alive. Last post was a few days ago I know.
I find Java a much cleaner language, not because it hides some of the things, but the syntax and what not is much cleaner and easier to read. As well as the fact they have one site where you can find almost any amount of information for it, including add ons and extensions. I think java is a better programming language, but its just not as fast in the long run. Learn them both, even though I talk to you quite a bit on line and helping u a bit lol.

Cj Shadows
01-16-2007, 09:32 PM
Well for C++ it is up for the programmer to make it clean and that may go with any language. Useing proper spacing and comments to give directions.

lothia
01-17-2007, 06:20 AM
I know but I am also talking about how the cin and cout look in the overall mass of things ;).
But yes it is completely the programmers job to make things look clean. Perhaps when I was talking about clean, I also was talking about readability

marx123
01-18-2007, 02:21 AM
Well since this topic for what ever reason is staying alive. Last post was a few days ago I know.
I find Java a much cleaner language, not because it hides some of the things, but the syntax and what not is much cleaner and easier to read. As well as the fact they have one site where you can find almost any amount of information for it, including add ons and extensions. I think java is a better programming language, but its just not as fast in the long run. Learn them both, even though I talk to you quite a bit on line and helping u a bit lol.

neat!
this is keep going

heheme and lothia turn to help each other in gmail..^__^