From: Roland Haeder Date: Fri, 2 Oct 2015 07:38:26 +0000 (+0200) Subject: keep some variables inside loop scope X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a5863ca6b281bc5d3a83ac5204ea11a169c87f83;p=jshop-core.git keep some variables inside loop scope Signed-off-by:Roland Häder --- diff --git a/src/org/mxchange/jshopcore/model/customer/CustomerUtils.java b/src/org/mxchange/jshopcore/model/customer/CustomerUtils.java index 5eb699c..e3e5cd7 100644 --- a/src/org/mxchange/jshopcore/model/customer/CustomerUtils.java +++ b/src/org/mxchange/jshopcore/model/customer/CustomerUtils.java @@ -58,24 +58,17 @@ public class CustomerUtils extends BaseFrameworkSystem { throw new IllegalStateException("Entity manager is closed."); } - // Fake customer instance - Customer customer = null; - // Generate number String customerNumber = null; // Default is found boolean isFound = true; - // Declare variables - long part1; - long part2; - // Is the number used? while (isFound) { // Both number parts - part1 = Math.round(Math.random() * 100_000); - part2 = Math.round(Math.random() * 1_000); + long part1 = Math.round(Math.random() * 100_000); + long part2 = Math.round(Math.random() * 1_000); // Generate new number customerNumber = String.format("%s-%s", part1, part2); //NOI18N @@ -83,7 +76,7 @@ public class CustomerUtils extends BaseFrameworkSystem { // Try it try { // Get instance - customer = em.getReference(ShopCustomer.class, customerNumber); + Customer customer = em.getReference(ShopCustomer.class, customerNumber); } catch (final EntityNotFoundException ex) { // Not found isFound = false;