面试时常问到这两种语言的区别,在此总结一下。

Referrence: Udemy:python-vs-java

Generally, Python is much simpler to use, and more compact than Java. It is generally easier to learn, and more forgiving when it comes to using shortcuts like reusing an old variable. You will also need fewer lines to write code in Python than in Java, partly due to the removal of the braces. As a side-effect, Python code is a bit easier to read and understand than Java.

Scripting Language vs Compiled Language

comparation

Dynamic vs Static Typing

Java: static typing

Python: dynamic typing

Java and Python differ in handling variables.

Java forces programmers to define the type of a variable when first declaring it. And Java will not allow you to cahnge the type later in the program.

Python allows programmers to change the type of a variable, like replacing an integer with a string.

Dynamic typing is easier for novice programmers.

But static typing can reduce the risk of undetected errors. When variables do not need to be explicitly declared before you use them, it is easy to misspell a variable name and accidentally create a whole new variable.

Braces vs Indentation

Python uses indentation to separate code into blocks.

Java, like most other languages, uses curly braces to define start and end of each funcation and class definition.

Advantage of using indentation:

1. Makes the program easy to read

2. Avoid errors resulting from a missing brace

Speed vs Portability

Java: "compile once, run everywhere" One major advantage of Java is that it can be used to create platform-independent applicaitons.

Whereas to run Python programs you need a compiler that can turn Python code into code that your particular operating system can understand.

Because most devices already have the Java virtual machine installed, so a Java programmer can be confident that their application will be usable by almost all users.

The disadvantage of running inside a virtual machine is that Java programs run more slowly than Python programs.

Java vs Python的更多相关文章

  1. Java集合-Python数据结构比较

    Java list与Python list相比较 Java List:有序的,可重复的.(有序指的是集合中对象的顺序与添加顺序相同) Python list(列表)是有序的,可变的. Java Lis ...

  2. windows、ubuntu下eclipse搭建java、Python环境问题总结

    前两篇博文分别讲述了如何在windows.ubuntu下用eclipse搭建java.python环境,下面就针对本人遇到的问题做一个总结. 一.windows下关于java环境变量JAVA_HOME ...

  3. ubuntu上用eclipse搭建java、python开发环境

    上一篇文章讲到如何在windwos上用eclipse搭建java.python开发环境,这一讲将关注如何在ubuntu上实现搭建,本人使用虚拟机安装的ubuntu系统,系统版本为:14.04 lts ...

  4. windows 下用eclipse搭建java、python开发环境

    本人只针对小白!本文只针对小白!本文只针对小白! 最近闲来无事,加上之前虽没有做过eclipse上java.python的开发工作,但一直想尝试一下.于是边查找资料边试验,花了一天时间在自己的机器上用 ...

  5. paip.元数据驱动的转换-读取文件行到个list理念 uapi java php python总结

    paip.元数据驱动的转换-读取文件行到个list理念 uapi java php python总结 #两个思路 1.思路如下:使用file_get_contents()获取txt文件的内容,然后通过 ...

  6. paip.提升安全性----Des加密 java php python的实现总结

    paip.提升安全性----Des加密 java php python的实现总结 ///////////    uapi         private static String decryptBy ...

  7. paip.抓取网页内容--java php python

    paip.抓取网页内容--java php python.txt 作者Attilax  艾龙, EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog ...

  8. paip.函数方法回调机制跟java php python c++的实现

    paip.函数方法回调机制跟java php python c++的实现 作者Attilax 艾龙,  EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http:// ...

  9. paip. uapi 过滤器的java php python 实现aop filter

    paip. uapi 过滤器的java php python 实现aop filter filter 是面向切面编程AOP.. 作者Attilax  艾龙,  EMAIL:1466519819@qq. ...

  10. paip. 调试技术打印堆栈 uapi print stack java php python 总结.

    paip. 调试技术打印堆栈 uapi print stack java php python 总结. 作者Attilax  艾龙,  EMAIL:1466519819@qq.com 来源:attil ...

随机推荐

  1. 《Unix环境高级编程》环境搭建

    用的是第三版的安装包:src.3e.tar.gz 地址:http://www.apuebook.com/ 1.解压:$ tar  -zxvf  *.tar.gz 2. $ cd apue.3e/ 3. ...

  2. Struts分页的一个实现

    在Web应用程序里,分页总让我们开发人员感到很头疼,倒不是因为技术上有多么困难,只是本来和业务没有太多关系的这么一个问题,你却得花不少功夫来处理.要是稍不留神,时不时出点问题就更郁闷了.我现在做的一个 ...

  3. python倒计时

    #coding=utf-8 #!/usr/bin/env python import datetime,time i=3 while i==3: spring=datetime.datetime(20 ...

  4. (转)iOS Wow体验 - 第二章 - iOS用户体验解析(2)

    本文是<iOS Wow Factor:Apps and UX Design Techniques for iPhone and iPad>第二章译文精选的第二部分,其余章节将陆续放出.上一 ...

  5. poj1014 Dividing (多重背包)

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:id=1014">http://poj.org/problem?id=1014 Descrip ...

  6. compareTo简介

    compareTo()方法是用来比较字符串大小,该方法用来判断一个字符串是大于,等于还是小于另一个字符串.判断字符串大小的依据是根据他们在字典中的顺序决定的 语法 Str1.compareTo(Str ...

  7. 设置单选的listView或者gridview

    主要是这个BeaseAdapter的方法notifyDataSetChanged()的使用;作用 :调用BaseAdapter中的getView();方法,刷新ListView中的数据.实现:1.在B ...

  8. contenteditable 属性

    定义和用法 contenteditable 属性规定是否可编辑元素的内容. 语法 <element contenteditable="value"> 属性值 值 描述 ...

  9. GDI+(Graphics Device Interface)

    1创建画布(创建Graphics对象) Bitmap bitmap = new Bitmap(80,80); Graphics g=Graphics.FromImage(bitmap); 2创建Pen ...

  10. vb将窗体中的控件或某种颜色透明

    Option Explicit ' ******************** 窗体透明 ******************** '***Module.bas '**** Public Declare ...