From 58c5ad97fc37884ec1c498921bf12f533e676afd Mon Sep 17 00:00:00 2001 From: Alena Bandarovich Date: Wed, 7 Feb 2024 20:33:03 +0100 Subject: [PATCH] Refactor: use yoda notation to get error in case of mistyping --- src/main/java/ChatClient.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/ChatClient.java b/src/main/java/ChatClient.java index afa6503..cd73618 100644 --- a/src/main/java/ChatClient.java +++ b/src/main/java/ChatClient.java @@ -20,7 +20,7 @@ public class ChatClient extends JFrame implements KeyListener { super("Chat"); address = JOptionPane.showInputDialog("bitte IP-Adresse"); - if (address != null) { + if (null != address) { receiveMessages(); } } @@ -47,8 +47,8 @@ public class ChatClient extends JFrame implements KeyListener { private void receiveMessages() { try { connectionToServer = new Socket(address, Constants.PORT); - fromServerReader = new BufferedReader(new InputStreamReader(connectionToServer.getInputStream())); - toServerWriter = new PrintWriter(new OutputStreamWriter(connectionToServer.getOutputStream())); + fromServerReader = new BufferedReader(new InputStreamReader(connectionToServer.getInputStream())); + toServerWriter = new PrintWriter(new OutputStreamWriter(connectionToServer.getOutputStream())); initGui();