Swift is used for developing software for Apple platforms (e.g. apps for iOS, macOS, etc.). Java on the other hand is universal. It can be used to write programs for the web, servers, Windows OS, Linux OS, Mac OS, Android OS, etc. Nevertheless, learning both languages is better .