1. String placehodler = 'Hello {0} , {1} is cool!';
  2. List<String> fillers = new String[]{'Jason','Apex'};
  3. String formatted = String.format(placehodler,fillers);
  4. System.assertEquals('Hello Jason , Apex is cool!',formatted);

结果如下所示

  1. Anonymous execution was successful.
  2.  
  3. 38.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
  4. Execute Anonymous: String placehodler = 'Hello {0} , {1} is cool!';
  5. Execute Anonymous: List<String> fillers = new String[]{'Jason','Apex'};
  6. Execute Anonymous: String formatted = String.format(placehodler,fillers);
  7. Execute Anonymous: System.assertEquals('Hello Jason , Apex is cool!',formatted);
  8. 13:50:33.21 (21991712)|USER_INFO|[EXTERNAL]|0056F00000652OT|weizhen.zhao@pactera.com|中国标准时间|GMT+08:00
  9. 13:50:33.21 (22007848)|EXECUTION_STARTED
  10. 13:50:33.21 (22013825)|CODE_UNIT_STARTED|[EXTERNAL]|execute_anonymous_apex
  11. 13:50:33.22 (22913817)|CUMULATIVE_LIMIT_USAGE
  12. 13:50:33.22 (22913817)|LIMIT_USAGE_FOR_NS|(default)|
  13. Number of SOQL queries: 0 out of 100
  14. Number of query rows: 0 out of 50000
  15. Number of SOSL queries: 0 out of 20
  16. Number of DML statements: 0 out of 150
  17. Number of DML rows: 0 out of 10000
  18. Maximum CPU time: 0 out of 10000
  19. Maximum heap size: 0 out of 6000000
  20. Number of callouts: 0 out of 100
  21. Number of Email Invocations: 0 out of 10
  22. Number of future calls: 0 out of 50
  23. Number of queueable jobs added to the queue: 0 out of 50
  24. Number of Mobile Apex push calls: 0 out of 10
  25.  
  26. 13:50:33.22 (22913817)|CUMULATIVE_LIMIT_USAGE_END
  27.  
  28. 13:50:33.21 (22953824)|CODE_UNIT_FINISHED|execute_anonymous_apex
  29. 13:50:33.21 (25331707)|EXECUTION_FINISHED

74、Salesforce的String的format方法的更多相关文章

  1. String的format方法

    摘自:http://xiongzhenhui.iteye.com/blog/940416 http://blueram.iteye.com/blog/441683 一.常规类型.字符类型和数值类型的格 ...

  2. 字符串格式化-String类format方法

    常规类型的格式化 String类的format()方法用于创建格式化的字符串以及连接多个字符串对象. format()方法有两种重载形式. 显示不同转换符实现不同数据类型到字符串的转换,如图所示: 测 ...

  3. Java中String类的format方法使用总结

    可参考: http://www.cnblogs.com/fsjohnhuang/p/4094777.html http://kgd1120.iteye.com/blog/1293633 String类 ...

  4. VFP自定义函数StringFormat (仿.NET String.Format 方法)

    VFP仿.NET String.Format 方法 将指定字符串中的每个{x}替换为相应值,并返回文本 *-- 调用格式 StringFormat("日期{2},字符{1}",&q ...

  5. php示例代码之类似于C#中的String.Format方法

    php示例代码之类似于C#中的String.Format方法 原文来自于  http://stackoverflow.com/questions/1241177/c-string-format-equ ...

  6. Java中利用MessageFormat对象实现类似C# string.Format方法格式化

    我们在写C#代码的时候常常会使用到string.Format("待格式化字符串{0},{1},....",参数1,参数2,...),来格式化字符串,特别是拼接字符的时候,这种方式使 ...

  7. java基础---->String和MessageFormat的format方法

    这里介绍一下String和MessageFormat中的format方法的差异以及实现原理. String与MessageFormat的说明 一.两者的使用场景 String.format:for l ...

  8. java字符串格式化:String.format()方法的使用

    转自:http://kgd1120.iteye.com/blog/1293633 常规类型的格式化 String类的format()方法用于创建格式化的字符串以及连接多个字符串对象.熟悉C语言的读者应 ...

  9. C# String.Format的格式限定符与Format方法将多个对象格式化一个字符串原理

    Format方法将多个对象格式化成一个字符串Format方法解析格式字符串的原理: (1).格式字符串中的{0}会被替换成格式字符串之后的第一个参数,以此类推 (2).Format方法解析格式字符串时 ...

随机推荐

  1. 老牌激活工具 — Microsoft Toolkit 2.5.1正式版【转】

    老牌激活工具 — Microsoft Toolkit 2.5.1正式版  Microsoft Toolkit 2.5.1是一个一键激活MS Office 及 win系统的工具.原理就是利用KMS来激活 ...

  2. selenium2-java 浏览器的三种弹窗处理

    alert弹窗 confirm弹窗 prompt弹窗 点击确定         // 选取警告弹窗           Alert alert=driver.switchTo().alert();   ...

  3. cortable 使用方法

    星期一到星期六,早上六点到晚上六点.每隔两个小时 执行语句 0 6-18/2  * * 1-6 commond

  4. Linux崩溃时启动脚本获取进程相关信息

    编写test.cpp #include <stdlib.h> #include <stdio.h> #include <exception> #include &l ...

  5. docker调用yum时“"/usr/libexec/urlgrabber-ext-down" is not installed”

    原因: 1 docker镜像为高版本的fedora30:latest镜像,yum本身已被dnf替代,但部分功能仍不完整: 如:yum-builddep SPECS/xxx.spec 解决办法: 1 安 ...

  6. this.$router.push相关的vue-router的导航方法

    this.$router.push相关的vue-router的导航方法:https://blog.csdn.net/zeroyulong/article/details/80312750

  7. Python基础篇(is和==)

    python基础篇(is,==,): 一.is和==的区别 1.id() 通过id()我们可以查看到一个变量表示的值在内存中的地址. s = 'alex' s = "alex" l ...

  8. centos7.3安装wordpress

    一.安装并配置数据库 1.安装mariadb #yum install -y mariadb-server mariadb 2.启动数据库并设置开机自启#systemctl start mariadb ...

  9. js自增++与自减--运算符

    /** * 自增(++)与自减(--)运算符 */ // 自增示例 var a = 1, c, d, e; console.log(`a++ = ${a++}`); // a++ = 1 consol ...

  10. 使用extract-text-webpack-plugin处理css文件路径问题

    首先看到我们的文件夹目录如下: webpack.config.js //解析分离cssconst ExtractTextPlugin = require('extract-text-webpack-p ...