Create a new image or share source code in a volume in a docker container in development?
In general the best practice would be to create a new image when you have new source code and run a new container from that image. Docker can quickly create and run new images, so you should take advantage of that. In addition you can know what version of your code you're running by tagging your images. 
You mention that you would need to compile the Java code in the Docker case, but you would need to in either case. You could just compile your code into a Jar and then ADD (or COPY) the Jar into your container and run it there.
A couple of quick downsides that come to mind with the external code approach: you would need some external way to manage what version of code is running, docker tags take care of that for you. You would also need some way to alert the Docker container that a new executable file is ready and then have Docker run that. In addition you would need to make sure that your Docker container is running the same version of Java (or Python) that your system is running, this too is taken care of in Docker since you can build from a Java base image.
I'm wondering what would be the best practice to update the source code in a docker container that is run within( in JAVA and python). I could either modify my code, create a new image and run a container. In Java,  I would also need to compile the code. 
Another solution would be to just use a volume to share the code between my machine and the container so that each time I modify the behavior of my code I won't need to create a new docker image.
I'm asking all of this for development purposes, not deploying
Is there a best practice between these two solutions? What are the pros and cons? Is there a difference for a compiled language like a java compared to python?