String str = String.format("Action %s occured on object %s.", objectA.getAction(), objectB);
Or
String str = String.format("Action %s occured on object %s with outcome %s.", new Object[]{objectA.getAction(), objectB, outcome});
You can also use numeric positions, for example to switch the parameters around:
String str = String.format("Action %2$s occured on object %1$s.", objectA.getAction(), objectB);
Related Posts:
- What does Java option -Xmx stand for? [duplicate]
- How to convert nanoseconds to seconds using the TimeUnit enum?
- Using or ‘|’ in regex [duplicate]
- && (AND) and || (OR) in IF statements
- Unable to find valid certification path to requested target – error even after cert imported
- Java – Convert integer to string [duplicate]
- How does System.out.print() work?
- Initialize part of an array in java
- What is the proper way to handle a NumberFormatException when it is expected?
- What causes “Unable to access jarfile” error?
- Where is JRE 11? [duplicate]
- Java – What does “\n” mean?
- What does “|=” mean? (pipe equal operator)
- What is the difference between a static method and a non-static method?
- Is there a method that calculates a factorial in Java?
- What is Java Servlet?
- Generating a Random Number between 1 and 10 Java
- Generating a Random Number between 1 and 10 Java [duplicate]
- How do I generate random integers within a specific range in Java?
- Best way to convert an ArrayList to a string
- How do I analyze a .mdmp file?
- Initialize List
- > in Java
- “No X11 DISPLAY variable” – what does it mean?
- en_US or en-US, which one should you use?
- javac : command not found
- Java says FileNotFoundException but file exists
- Why am I getting InputMismatchException?
- Java integer list
- How can I properly compare two Integers in Java?
- element not interactable exception in selenium web automation
- Difference in System. exit(0) , System.exit(-1), System.exit(1 ) in Java
- Exception in thread “main” java.lang.UnsupportedClassVersionError: a (Unsupported major.minor version 51.0)
- How to compare two double values in Java?
- Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0 error in Java
- How to override compareTo (Java)
- Why do I get an UnsupportedOperationException when trying to remove an element from a List?
- java.util.NoSuchElementException: No line found
- How to check whether a int is not null or empty?
- How to parse JSON in Java
- Declaring an unsigned int in Java
- Converting Hexadecimal String to Decimal Integer
- LocalDate to java.util.Date and vice versa simplest conversion?
- Required: Variable Found: Value
- What does the colon (:) operator do?
- Shifting array to the right – homework
- How to get rid of Checkstyle message ‘File does not end with a newline.’
- Uri not Absolute exception getting while calling Restful Webservice
- Very Basic Java
- SQLRecoverableException: I/O Exception: Connection reset
- What exactly is a Maven Snapshot and why do we need it?
- How to check if my string is equal to null?
- what is Ljava.lang.String;@
- “Could not find Java SE Runtime Environment.” after installing Java
- How can I create an utility class?
- difference between ‘static int’ and ‘int’ in java
- How to use PrintWriter and File classes in Java?
- JAVA_HOME should point to a JDK not a JRE
- This Activity already has an action bar supplied by the window decor?
- Convert hex string to int
- Orphaned Case Error in Java
- Proxy Error 502 : The proxy server received an invalid response from an upstream server
- Java double.MAX_VALUE?
- how to do a system pause in java for debugging?
- Immutable class?
- Is spring default scope singleton or not?
- Java Reflection – Object is not an instance of declaring class
- What does “AL lib: alc_cleanup: 1 device not closed” mean?
- (Java) Tic-Tac-Toe game using 2 dimensional Array
- Incompatible types List of List and ArrayList of ArrayList
- Dice Rolling java program
- int cannot be converted to int []
- Joda DateTime to Timestamp conversion
- break statement in “if else” – java
- What is the difference between JSF, Servlet and JSP?
- Get only part of an Array in Java?
- How to Get JSON Array Within JSON Object?
- What is a class constant?
- How to represent a fix number of repeats in regular expression?
- How to import a jar in Eclipse
- Java equivalent of unsigned long long?
- Getting “unixtime” in Java
- How do I break out of nested loops in Java?
- How do I convert this for loop into a while loop?
- Java switch statement: Constant expression required, but it IS constant
- Resolving File paths – ‘File not found’ error in Eclipse
- Simple Coin Toss using random class in Java. The do while loop doesn’t seem to generate random results
- Why I am getting DefaultHttpClient is deprecated?
- When should you use multithreading? And would multi threading be beneficial if the different threads execute mutually independent tasks?
- How to Convert Int to Unsigned Byte and Back
- Suggestions needed: Effective Java to C source code converter
- Downloading a file from spring controllers
- How do I autoindent in Netbeans?
- What is an attribute in Java?
- MessageBodyWriter not found for media type=application/json
- Conversion from Long to Double in Java
- Failed to find Java VM
- Java regex email
- Java Iterator on Doubly-linked-list
- Why “no projects found to import”?
- Java Swing setting JPanel Size