Comparisons between Java and Python

by lotusithub

Difference between Java and Python:

Following are the major difference between java and python

Comparisons between Java and Python

Sr.no. Java Python
1 Java is object-oriented programming language. Functional programming features are introduced into java 8.0 through lambda expressions. Python blends functional programming with object-oriented programming features. Lambdas are already available in python.
2 Java programs are verbose. It means they contain more number of lines. Python programs are concise and compact. A big program can be written using very less number of lines.
3 It is compulsory to declare the data types  Type Declaration is not required in python
4 Java language type discipline is static and weak. Python type discipline is dynamic and strong.
5 Java has do… while, while, for each loops. Python has while and for loops.
6 Java has switch statement. Python does not have switch statement.
7 The variable in the loop does not increment automatically .but in for each loop, it will increment automatically. The variable in the loop increments automatically.
8 Memory allocation and deallocation is done automatically by JVM (java virtual Machine). Memory allocation and deallocation is done automatically by PVM (Python virtual Machine).
9 Java a supports single and multi-dimensional arrays. Python support only single dimensional arrays. to work with multidimensional arrays, we should use third party application like numpy.
10 The array index should be a positive integer. Array index can be positive or negative integer number. Negative index represents a location from the end of the array.
11 For display output 

->System.out.println(“Lotus IT Hub.com”);

For display output 

->print(“Lotus IT Hub.com!!”)

or

->print(‘Lotus IT Hub.com!!’)

or

->print(‘’’ Lotus IT Hub.com!!’’’)

12 If else statements

class Lotus

{

public static void main(String args[])
{

int a=100,b=20;

if(a>b)

{
System.out.println(“A is Greater than B”)
}

else

{

System.out.println(“B is Greater than A”);

}
}

}  

a=1000

b=20

If a>b:

  print(“A is Greater than B”)

else:

   print(“B is Greater than A”)

13 Indention of statement s is not necessary in java. Indention is required to represent a block of statements.

 

Related Posts

Leave a Comment